wallet_send_transaction
Send Ethereum or EVM-compatible blockchain transactions using wallet credentials, specifying recipient, value, gas, and other parameters to execute transfers or contract interactions.
Instructions
Send a transaction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transaction | Yes | The transaction to send | |
| wallet | No | The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set. |
Implementation Reference
- src/handlers/wallet.ts:319-343 (handler)The sendTransactionHandler function implements the core logic for the wallet_send_transaction tool. It validates input, retrieves the wallet, ensures a provider is set, sends the transaction via wallet.sendTransaction(input.transaction), and returns transaction details or an error.export const sendTransactionHandler = async (input: any): Promise<ToolResultSchema> => { try { if (!input.transaction) { return createErrorResponse("Transaction is required"); } const wallet = await getWallet(input.wallet, input.password); if (!wallet.provider) { return createErrorResponse("Provider is required to send a transaction, please set the provider URL"); } const tx = await wallet.sendTransaction(input.transaction); return createSuccessResponse( `Transaction sent successfully Hash: ${tx.hash} Nonce: ${tx.nonce.toString()} Gas limit: ${tx.gasLimit.toString()} Gas price: ${tx.gasPrice?.toString()} Data: ${tx.data} `); } catch (error) { return createErrorResponse(`Failed to send transaction: ${(error as Error).message}`); } };
- src/tools.ts:249-276 (schema)Defines the input schema and description for the wallet_send_transaction tool, specifying the required transaction object with fields like to, data, value, etc.{ name: "wallet_send_transaction", description: "Send a transaction", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set." }, transaction: { type: "object", description: "The transaction to send", properties: { to: { type: "string" }, from: { type: "string" }, data: { type: "string" }, value: { type: "string" }, gasLimit: { type: "string" }, gasPrice: { type: "string" }, nonce: { type: "number" }, type: { type: "number" }, maxFeePerGas: { type: "string" }, maxPriorityFeePerGas: { type: "string" } }, required: ["to"] } }, required: ["transaction"] } },
- src/tools.ts:579-579 (registration)Maps the tool name 'wallet_send_transaction' to its handler function sendTransactionHandler in the handlers dictionary."wallet_send_transaction": sendTransactionHandler,