Skip to main content
Glama

transferNativeToken

Transfer BNB tokens between addresses securely on Binance Smart Chain through the BSC MCP Server. Specify recipient and amount for direct native token transactions.

Instructions

Transfer native token (BNB)

Input Schema

NameRequiredDescriptionDefault
amountYes
recipientAddressYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "amount": { "type": "string" }, "recipientAddress": { "type": "string" } }, "required": [ "recipientAddress", "amount" ], "type": "object" }

Implementation Reference

  • Handler function that sends native token (BNB) transaction using walletClient.sendTransaction to the recipient address with parsed amount, handles success and error responses with transaction URLs.
    async ({ recipientAddress, amount }) => { let txHash = undefined; try { const account = await getAccount(); txHash = await walletClient(account).sendTransaction({ to: recipientAddress as `0x${string}`, value: parseEther(amount), }); const txUrl = await checkTransactionHash(txHash) return { content: [ { type: "text", text: `Transaction sent successfully. ${txUrl}`, url: txUrl, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); const txUrl = buildTxUrl(txHash); return { content: [ { type: "text", text: `transaction failed: ${errorMessage}`, url: txUrl, }, ], isError: true, }; } }
  • Input schema defining recipientAddress and amount as strings, validated with Zod.
    recipientAddress: z.string(), amount: z.string(), },
  • Registration function that adds the 'Send_BNB' tool to the MCP server with description, input schema, and handler.
    export function registerTransferNativeToken(server: McpServer) { server.tool("Send_BNB", "💎Transfer native token (BNB), Before execution, check the wallet information first", { recipientAddress: z.string(), amount: z.string(), }, async ({ recipientAddress, amount }) => { let txHash = undefined; try { const account = await getAccount(); txHash = await walletClient(account).sendTransaction({ to: recipientAddress as `0x${string}`, value: parseEther(amount), }); const txUrl = await checkTransactionHash(txHash) return { content: [ { type: "text", text: `Transaction sent successfully. ${txUrl}`, url: txUrl, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); const txUrl = buildTxUrl(txHash); return { content: [ { type: "text", text: `transaction failed: ${errorMessage}`, url: txUrl, }, ], isError: true, }; } } ); }
  • src/main.ts:27-27 (registration)
    Calls the registerTransferNativeToken function to register the tool on the main MCP server instance.
    registerTransferNativeToken(server);
  • src/main.ts:7-7 (registration)
    Imports the registerTransferNativeToken function from the tool module.
    import { registerTransferNativeToken } from "./tools/transferNativeToken.js";

Other Tools

Related Tools

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/TermiX-official/bsc-mcp'

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