import { Connection } from "@solana/web3.js"; import { DepositCommitment, PermissionlessClient, SolanaChainEnum, } from "../../src"; import { DepositMode } from "../../src/types/metadata"; import { BN } from "@coral-xyz/anchor"; import dotenv from "dotenv"; import { Keypair } from "@solana/web3.js"; dotenv.config(); async function main() { const connection = new Connection(process.env.RPC_URL!); const client = new PermissionlessClient( process.env.RPC_URL!, SolanaChainEnum.DEVNET, ); const key = Keypair.fromSecretKey( new Uint8Array(JSON.parse(process.env.PRIVATE_KEY!)), ); // Note: 1 USDC is the minimum deposit amount const tx = await client.buildDepositTx( key.publicKey, new BN(1_000_000), DepositMode.CLASSIC, ); console.log(tx); if (!tx) { console.error( "Failed to build deposit transaction, maximum deposit amount possibly exceeded", ); return; } tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash; await tx.sign(key); const txHash = await connection.sendRawTransaction(tx.serialize()); console.log(txHash); } main();