Skip to main content
Glama

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
NameRequiredDescriptionDefault
fromWalletYesName of the sender wallet
toAddressYesRecipient address
amountYesAmount in SOL

Implementation Reference

  • 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}` }; }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ExpertVagabond/solana-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server