Skip to main content
Glama

send-transaction

Initiate blockchain transactions by specifying recipient, value, gas fees, and chain ID. Use this tool to securely interact with networks, with private keys managed in MetaMask.

Instructions

Send transactions to networks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoChain ID to validate against before sending transaction.
dataNoA contract hashed method call with encoded args.
maxFeePerGasNoTotal fee per gas in wei, inclusive of maxPriorityFeePerGas.
maxPriorityFeePerGasNoMax priority fee per gas in wei.
toYesThe transaction recipient or contract address.
valueNoValue in wei sent with this transaction.

Implementation Reference

  • The execute handler for the 'send-transaction' tool. It sends the transaction using wagmi's sendTransaction, returns the transaction hash as JSON string, or the error message if failed.
    execute: async (args) => { try { const result = await sendTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify({ hash: result, }), }, ], }; } catch (error) { if (error instanceof TransactionExecutionError) { return { content: [ { type: "text", text: error.cause.message, }, ], }; } return { content: [ { type: "text", text: (error as Error).message, }, ], }; } },
  • Zod input schema defining parameters for the send-transaction tool: to (address), data (calldata optional), value, gas fees, chainId.
    parameters: z.object({ to: Address.describe("The transaction recipient or contract address."), data: Address.optional().describe("A contract hashed method call with encoded args."), value: z.coerce.bigint().optional().describe("Value in wei sent with this transaction."), maxFeePerGas: z.coerce.bigint().optional().describe("Total fee per gas in wei, inclusive of maxPriorityFeePerGas."), maxPriorityFeePerGas: z.coerce.bigint().optional().describe("Max priority fee per gas in wei."), chainId: z.coerce.number().optional().describe("Chain ID to validate against before sending transaction."), }),
  • Registration function that adds the 'send-transaction' tool to the FastMCP server using server.addTool, including name, description, schema, and handler.
    export function registerSendTransactionTools(server: FastMCP, wagmiConfig: Config): void { server.addTool({ name: "send-transaction", description: "Send transactions to networks.", parameters: z.object({ to: Address.describe("The transaction recipient or contract address."), data: Address.optional().describe("A contract hashed method call with encoded args."), value: z.coerce.bigint().optional().describe("Value in wei sent with this transaction."), maxFeePerGas: z.coerce.bigint().optional().describe("Total fee per gas in wei, inclusive of maxPriorityFeePerGas."), maxPriorityFeePerGas: z.coerce.bigint().optional().describe("Max priority fee per gas in wei."), chainId: z.coerce.number().optional().describe("Chain ID to validate against before sending transaction."), }), execute: async (args) => { try { const result = await sendTransaction(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify({ hash: result, }), }, ], }; } catch (error) { if (error instanceof TransactionExecutionError) { return { content: [ { type: "text", text: error.cause.message, }, ], }; } return { content: [ { type: "text", text: (error as Error).message, }, ], }; } }, }); };
  • Central registration point where registerSendTransactionTools is invoked as part of registerTools function.
    registerSendTransactionTools(server, wagmiConfig);

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/Xiawpohr/metamask-mcp'

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