transfer_sol
Transfer SOL tokens between wallets on the Solana blockchain by specifying sender wallet, recipient address, and amount.
Instructions
Transfer SOL between wallets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromWallet | Yes | Name of the sender wallet | |
| toAddress | Yes | Recipient address | |
| amount | Yes | Amount in SOL |
Implementation Reference
- src/index.ts:636-669 (handler)The `handleTransferSol` function implements the core logic for transferring SOL: retrieves sender wallet, ensures connection, calculates lamports, builds and signs a transaction using SystemProgram.transfer, sends it, and returns the transaction signature with explorer URL.async function handleTransferSol(args: any) { const { fromWallet, toAddress, amount } = args; const wallet = wallets.get(fromWallet); if (!wallet) { throw new Error(`Wallet '${fromWallet}' not found`); } ensureConnection(); const toPubkey = new PublicKey(toAddress); const lamports = Math.floor(amount * LAMPORTS_PER_SOL); const transaction = new Transaction().add( SystemProgram.transfer({ fromPubkey: wallet.keypair.publicKey, toPubkey: toPubkey, lamports: lamports, }) ); const { blockhash } = await connection.getLatestBlockhash(); transaction.recentBlockhash = blockhash; transaction.feePayer = wallet.keypair.publicKey; transaction.sign(wallet.keypair); const signature = await connection.sendTransaction(transaction, [wallet.keypair]); return { success: true, signature, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
- src/index.ts:149-165 (schema)Input schema (JSON Schema) for the transfer_sol tool, defining required parameters: fromWallet (string), toAddress (string), amount (number).inputSchema: { type: "object", properties: { fromWallet: { type: "string", description: "Name of the sender wallet" }, toAddress: { type: "string", description: "Recipient address" }, amount: { type: "number", description: "Amount in SOL" } }, required: ["fromWallet", "toAddress", "amount"]
- src/index.ts:146-167 (registration)Registration of the transfer_sol tool in the `tools` array, which is served via the ListToolsRequestSchema handler. Includes name, description, and inputSchema.{ name: "transfer_sol", description: "Transfer SOL between wallets", inputSchema: { type: "object", properties: { fromWallet: { type: "string", description: "Name of the sender wallet" }, toAddress: { type: "string", description: "Recipient address" }, amount: { type: "number", description: "Amount in SOL" } }, required: ["fromWallet", "toAddress", "amount"] } },
- src/index.ts:1300-1301 (registration)Dispatch/registration in the switch statement of the CallToolRequestSchema handler, mapping tool name to the handler function.case "transfer_sol": result = await handleTransferSol(args);