Skip to main content
Glama

transfer_apt

Send APT tokens to another Aptos account securely. Specify recipient address and amount to initiate transfer. Returns transaction hash for tracking.

Instructions

Transfer native APT tokens to another Aptos account. This is used for sending APT tokens from your account to another address. Returns the transaction hash upon successful transfer.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount of APT to transfer (e.g., '1.5' for 1.5 APT)
max_gas_amountNoMaximum gas amount for the transaction (optional)
recipient_addressYesRecipient Aptos address, e.g., 0x1 or 0x742d35Cc6634C0532925a3b8D6Ac0C4db9c8b3

Implementation Reference

  • Main handler function for the 'transfer_apt' tool. Validates input arguments using isTransferAptArgs and delegates the transfer logic to performTransferApt, handling success/error responses.
    export async function transferAptHandler(args: Record<string, any> | undefined) { if (!isTransferAptArgs(args)) { throw new Error("Invalid arguments for transfer_apt"); } const { recipient_address, amount, max_gas_amount = 2000 } = args; try { const results = await performTransferApt(recipient_address, amount, max_gas_amount); return { content: [{ type: "text", text: results }], isError: false, }; } catch (error) { return { content: [ { type: "text", text: `Error transferring APT: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Tool schema definition for 'transfer_apt', specifying input parameters: recipient_address (string, required), amount (string, required), max_gas_amount (number, optional).
    export const TRANSFER_APT: Tool = { name: "transfer_apt", description: "Transfer native APT tokens to another Aptos account. This is used for sending APT tokens from your account to another address. Returns the transaction hash upon successful transfer.", inputSchema: { type: "object", properties: { recipient_address: { type: "string", description: "Recipient Aptos address, e.g., 0x1 or 0x742d35Cc6634C0532925a3b8D6Ac0C4db9c8b3", }, amount: { type: "string", description: "Amount of APT to transfer (e.g., '1.5' for 1.5 APT)", }, max_gas_amount: { type: "number", description: "Maximum gas amount for the transaction (optional)", default: 2000, }, }, required: ["recipient_address", "amount"], }, };
  • Core implementation of APT transfer: builds transaction using Aptos SDK '0x1::aptos_account::transfer', signs/submits it with sender account, waits for confirmation, and returns formatted success message with tx details.
    export async function performTransferApt( recipientAddress: string, amount: string, maxGasAmount: number = 2000 ): Promise<string> { try { const aptos = getAptosClient(); const senderAccount = getDefaultAccount(); // Convert APT amount to Octas const amountOctas = aptToOctas(amount); // Build the transfer transaction const transaction = await aptos.transaction.build.simple({ sender: senderAccount.accountAddress, data: { function: "0x1::aptos_account::transfer", functionArguments: [recipientAddress, amountOctas], }, options: { maxGasAmount, }, }); // Sign and submit the transaction const committedTxn = await aptos.signAndSubmitTransaction({ signer: senderAccount, transaction, }); // Wait for transaction confirmation const executedTxn = await aptos.waitForTransaction({ transactionHash: committedTxn.hash, }); return `APT Transfer Successful: From: ${formatAddress(senderAccount.accountAddress.toString())} To: ${formatAddress(recipientAddress)} Amount: ${amount} APT (${amountOctas} Octas) Transaction Hash: ${committedTxn.hash} Gas Used: ${executedTxn.gas_used} Status: ${executedTxn.success ? 'Success' : 'Failed'} ✅ Transfer completed successfully!`; } catch (error) { console.error('Error transferring APT:', error); if (error instanceof Error) { if (error.message.includes('insufficient')) { throw new Error("Insufficient APT balance to complete the transfer"); } if (error.message.includes('invalid')) { throw new Error("Invalid recipient address format"); } } throw new Error(`Failed to transfer APT: ${error instanceof Error ? error.message : String(error)}`); } }
  • src/index.ts:122-123 (registration)
    Registration/dispatch of transfer_apt handler in the main MCP server's tool call switch statement.
    case "transfer_apt": return await transferAptHandler(args);
  • Registration/dispatch of transfer_apt handler in the HTTP MCP server's tool call switch statement.
    case "transfer_apt": return await transferAptHandler(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/punkpeye/aptos-mcp'

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