Skip to main content
Glama

send-transaction

Send blockchain transactions to recipients or smart contracts using MetaMask MCP, specifying recipients, values, gas fees, and chain IDs for secure execution.

Instructions

Send transactions to networks.

Input Schema

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

Implementation Reference

  • Handler function that executes the send-transaction tool by calling wagmi's sendTransaction, returning the transaction hash or error message.
    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 schema defining the input parameters for the send-transaction tool.
    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."), }),
  • Function that registers the send-transaction tool with FastMCP server, defining 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, }, ], }; } }, }); };
  • Call to register the send-transaction tool as part of the central tools registration.
    registerSendTransactionTools(server, wagmiConfig);
  • src/index.ts:15-15 (registration)
    Top-level call to register all tools, including send-transaction.
    registerTools(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