transfer_sol
Transfer SOL tokens between wallets on the Solana blockchain. Specify sender wallet, recipient address, and amount to execute the transaction.
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 main handler function that performs the SOL transfer: retrieves sender wallet, builds a transaction using SystemProgram.transfer, sets recent blockhash and fee payer, signs with the wallet keypair, sends the transaction, and returns the signature and 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-166 (schema)Zod-compatible input schema defining the 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)Tool registration entry in the tools array returned by ListToolsRequestHandler, defining name, description, and input schema.{ 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)Switch case in CallToolRequestHandler that dispatches calls to the transfer_sol tool to the handleTransferSol function.case "transfer_sol": result = await handleTransferSol(args);