send_usdc
Send USDC cryptocurrency to Solana addresses on devnet. Execute real blockchain transactions by specifying recipient and amount.
Instructions
Send USDC to another Solana address. This executes a real transaction on Solana devnet.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| recipient | Yes | The Solana address to send USDC to | |
| amount | Yes | Amount of USDC to send (e.g., 5.00 for $5) | |
| memo | No | Optional memo/note for the transaction |
Implementation Reference
- src/index.ts:147-167 (handler)MCP tool handler for 'send_usdc': destructures arguments from request, invokes wallet.sendUsdc, and returns formatted success response with transaction explorer link.case "send_usdc": { const { recipient, amount, memo } = args as { recipient: string; amount: number; memo?: string; }; const result = await wallet.sendUsdc(recipient, amount, memo); return { content: [ { type: "text", text: JSON.stringify({ success: true, ...result, explorer: `https://explorer.solana.com/tx/${result.signature}?cluster=devnet`, }, null, 2), }, ], }; }
- src/index.ts:43-64 (registration)Registers the 'send_usdc' tool in the TOOLS list, including name, description, and input schema for MCP tool listing.{ name: "send_usdc", description: "Send USDC to another Solana address. This executes a real transaction on Solana devnet.", inputSchema: { type: "object", properties: { recipient: { type: "string", description: "The Solana address to send USDC to", }, amount: { type: "number", description: "Amount of USDC to send (e.g., 5.00 for $5)", }, memo: { type: "string", description: "Optional memo/note for the transaction", }, }, required: ["recipient", "amount"], }, },
- src/wallet.ts:138-206 (helper)Core implementation of USDC transfer: validates balance, creates associated token accounts if needed, builds SPL transfer transaction, and sends/confirms on Solana devnet.async sendUsdc( recipientAddress: string, amount: number, memo?: string ): Promise<TransactionResult> { const recipient = new PublicKey(recipientAddress); const sender = this.keypair.publicKey; // Get ATAs const senderAta = await getAssociatedTokenAddress(USDC_MINT, sender); const recipientAta = await getAssociatedTokenAddress(USDC_MINT, recipient); // Check sender has enough USDC try { const senderAccount = await getAccount(this.connection, senderAta); const balance = Number(senderAccount.amount) / Math.pow(10, USDC_DECIMALS); if (balance < amount) { throw new Error(`Insufficient USDC balance. Have: ${balance}, Need: ${amount}`); } } catch (error: any) { if (error.message?.includes("Insufficient")) { throw error; } throw new Error("No USDC token account found. Request devnet USDC first."); } // Build transaction const transaction = new Transaction(); // Check if recipient ATA exists, if not create it try { await getAccount(this.connection, recipientAta); } catch { // Create recipient ATA transaction.add( createAssociatedTokenAccountInstruction( sender, // payer recipientAta, // ata address recipient, // owner USDC_MINT // mint ) ); } // Add transfer instruction const amountInBaseUnits = Math.floor(amount * Math.pow(10, USDC_DECIMALS)); transaction.add( createTransferInstruction( senderAta, recipientAta, sender, amountInBaseUnits ) ); // Send transaction const signature = await sendAndConfirmTransaction( this.connection, transaction, [this.keypair] ); return { signature, recipient: recipientAddress, amount, memo, }; }