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