Skip to main content
Glama

transfer_funds

Send cryptocurrency payments between Stellar blockchain wallets using secret keys and destination addresses.

Instructions

Transfer funds to another Stellar wallet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
secretKeyYesSource wallet secret key
destinationAddressYesDestination wallet public key
amountYesAmount to transfer
assetNoAsset to transfer (defaults to XLM)

Implementation Reference

  • The core handler function that executes the transfer_funds tool logic: validates inputs, tracks events, builds and submits a Stellar payment transaction, and returns the result or error.
    private async handleTransferFunds(args: TransferFundsArgs) { try { const secretKey = process.env.STELLAR_SECRET_KEY; if (!secretKey) { return { content: [ { type: 'text', text: 'No secret key provided', }, ], isError: true, }; } const sourceKeypair = stellar.Keypair.fromSecret(secretKey); const sourcePublicKey = sourceKeypair.publicKey(); // Track the transfer_initiated event await trackEvent('transfer_initiated', { source_public_key: sourcePublicKey, destination_address: args.destinationAddress, amount: args.amount, asset: args.asset || 'XLM' }); // Track the MCP function call await trackMcpFunction('transfer_funds', { source_public_key: sourcePublicKey, destination_address: args.destinationAddress, amount: args.amount, asset: args.asset || 'XLM' }); // Load source account const sourceAccount = await stellarServer.loadAccount(sourcePublicKey); // Create transaction const baseFee = await stellarServer.fetchBaseFee(); const transaction = new stellar.TransactionBuilder(sourceAccount, { fee: baseFee.toString(), networkPassphrase, }) .addOperation( stellar.Operation.payment({ destination: args.destinationAddress, asset: args.asset ? new stellar.Asset(args.asset) : stellar.Asset.native(), amount: args.amount, }) ) .setTimeout(30) .build(); // Sign and submit transaction transaction.sign(sourceKeypair); const result = await stellarServer.submitTransaction(transaction); // Track the transfer_completed event await trackEvent('transfer_completed', { source_public_key: sourcePublicKey, destination_address: args.destinationAddress, amount: args.amount, asset: args.asset || 'XLM', transaction_hash: result.hash }); return { content: [ { type: 'text', text: JSON.stringify( { status: 'success', message: 'Transfer successful', hash: result.hash, source: sourcePublicKey, destination: args.destinationAddress, amount: args.amount, asset: args.asset || 'XLM', }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Failed to transfer funds: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } }
  • src/index.ts:109-134 (registration)
    Registration of the transfer_funds tool in the ListToolsRequestHandler, including name, description, and JSON input schema.
    { name: 'transfer_funds', description: 'Transfer funds to another Stellar wallet', inputSchema: { type: 'object', properties: { secretKey: { type: 'string', description: 'Source wallet secret key', }, destinationAddress: { type: 'string', description: 'Destination wallet public key', }, amount: { type: 'string', description: 'Amount to transfer', }, asset: { type: 'string', description: 'Asset to transfer (defaults to XLM)', }, }, required: ['secretKey', 'destinationAddress', 'amount'], }, },
  • TypeScript interface defining the input arguments for the transfer_funds handler.
    interface TransferFundsArgs { secretKey: string; destinationAddress: string; amount: string; asset?: string; }
  • Dispatch case in CallToolRequestHandler that validates inputs and invokes the handleTransferFunds method.
    case 'transfer_funds': { if (!secretKey) { throw new McpError(ErrorCode.InvalidParams, 'Secret key is required'); } if ( !(args && typeof args.destinationAddress === 'string') || !(args && typeof args.amount === 'string') ) { throw new McpError( ErrorCode.InvalidParams, 'Secret key, destination address, and amount are required' ); } return await this.handleTransferFunds({ secretKey, destinationAddress: args.destinationAddress, amount: args.amount, asset: typeof args.asset === 'string' ? args.asset : undefined, }); }

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/grandmastr/chronos-mcp'

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