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
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | The transaction recipient or contract address. | |
| data | No | A contract hashed method call with encoded args. | |
| value | No | Value in wei sent with this transaction. | |
| maxFeePerGas | No | Total fee per gas in wei, inclusive of maxPriorityFeePerGas. | |
| maxPriorityFeePerGas | No | Max priority fee per gas in wei. | |
| chainId | No | Chain ID to validate against before sending transaction. |
Implementation Reference
- src/tools/send-transaction.ts:21-55 (handler)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, }, ], }; } },
- src/tools/send-transaction.ts:13-20 (schema)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."), }),
- src/tools/send-transaction.ts:9-57 (registration)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, }, ], }; } }, }); };
- src/tools/register-tools.ts:52-52 (registration)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);