send-transaction
Execute blockchain transactions by specifying recipient addresses, values, and data payloads to interact securely with decentralized networks.
Instructions
Send transactions to networks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | ||
| value | No | ||
| data | No |
Implementation Reference
- The execute handler for the 'send-transaction' tool. It sends a transaction using wagmi/core's sendTransaction with parameters to, value (optional), data (optional). Returns the transaction hash in JSON or an error message in MCP content format, handling TransactionExecutionError specifically.execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await sendTransaction(wagmiConfig, { to, value, data, }) 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 the parameters for the send-transaction tool: 'to' (required string), 'value' (optional coercible number), 'data' (optional string).parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }),
- packages/metamask-mcp/src/tools/send-transaction.ts:8-59 (registration)The registration function that defines and adds the 'send-transaction' tool to the FastMCP server instance, including name, description, schema, and handler.export function registerSendTransactionTools(server: FastMCP): void { server.addTool({ name: "send-transaction", description: "Send transactions to networks", parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }), execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await sendTransaction(wagmiConfig, { to, value, data, }) 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, } ] } } }, }); };
- packages/metamask-mcp/src/index.ts:55-55 (registration)Invocation of the registerSendTransactionTools function during server initialization to register the tool on the main FastMCP server.registerSendTransactionTools(server);