wallet_populate_transaction
Complete Ethereum and EVM-compatible transactions by auto-filling missing fields such as gas, nonce, or fees using wallet details and transaction data.
Instructions
Populate a transaction with missing fields
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transaction | Yes | The transaction to populate | |
| 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:366-391 (handler)The core handler function that populates the transaction object using the ethers Wallet's populateTransaction method, filling in missing fields like nonce, gas, etc., based on the provider.export const populateTransactionHandler = 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 populate a transaction, please set the provider URL"); } const populatedTx = await wallet.populateTransaction(input.transaction); return createSuccessResponse( `Transaction populated successfully To: ${populatedTx.to} From: ${populatedTx.from} Nonce: ${populatedTx.nonce?.toString() ?? "Not specified"} Gas limit: ${populatedTx.gasLimit?.toString() ?? "Not specified"} Gas price: ${populatedTx.gasPrice?.toString() ?? "Not specified"} `); } catch (error) { return createErrorResponse(`Failed to populate transaction: ${(error as Error).message}`); } };
- src/tools.ts:305-332 (schema)The input schema definition for the wallet_populate_transaction tool, specifying parameters like wallet and transaction object.{ name: "wallet_populate_transaction", description: "Populate a transaction with missing fields", 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 populate", 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:581-581 (registration)The registration of the populateTransactionHandler to the 'wallet_populate_transaction' tool name in the handlers dictionary."wallet_populate_transaction": populateTransactionHandler,