Transaction simulation (eth_call + gas)
POST /api/tx-simulateDry-run a prospective smart-contract call or transaction without broadcasting it: executes eth_call and eth_estimateGas against the latest block over the same keyless multi-endpoint public RPC pool as /api/evm-rpc (ethereum, base, polygon, arbitrum, optimism). Send POST /api/tx-simulate with the required field to and pay $0.005 per call over x402 or MPP (there is no free tier). It returns a JSON object with network, success, returnData, gasEstimate and revertReason.
Returns the return data and a gas estimate on success, or {success:false} with the revert reason when the call would fail. Strictly read-only - nothing is signed or broadcast.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
to | string | yes | 0x-prefixed 40-char target contract/account address. Also accepted as target, dest, destination, end. |
data | string | no | 0x-prefixed calldata (default 0x - plain value transfer). |
from | string | no | Optional sender address (default zero address). |
value | string | no | Optional value in wei - decimal string or 0x hex (default 0). |
network | string | no | ethereum / base / polygon / arbitrum / optimism (default base). |
Example request
curl -i -X POST https://agent402.tools/api/tx-simulate \
-H "Content-Type: application/json" \
-d '{"network":"base","to":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","data":"0x70a08231000000000000000000000000abf4fabd7c416fb67202e5f9002389fc75e2a9d0"}'
Without payment this returns HTTP 402 Payment Required with the exact price for tx-simulate; any x402 v2 or MPP client pays it and retries.
Example response
{
"network": "base",
"success": true,
"returnData": "0x00000000000000000000000000000000000000000000000000000000000f4240",
"gasEstimate": 31234,
"revertReason": null
}
| Field | Type | Always present | In the example |
|---|---|---|---|
network | string | yes | base |
success | boolean | yes | true |
returnData | string | yes | 0x00000000000000000000000000000000000000000000000000000000000f4240 |
gasEstimate | number | yes | 31234 |
revertReason | null | no | null |
From an MCP client
catalog.call {
"slug": "tx-simulate",
"params": {
"network": "base",
"to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"data": "0x70a08231000000000000000000000000abf4fabd7c416fb67202e5f9002389fc75e2a9d0"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for tx-simulate; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
tois required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement is cancelled when the tool fails. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/tx-simulate returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/tx-simulate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"network": "base",
"to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"data": "0x70a08231000000000000000000000000abf4fabd7c416fb67202e5f9002389fc75e2a9d0"
}),
});
Part of these workflows
Transaction simulation (eth_call + gas) is one step in this skill pack, each sold as a single call:
- Contract audit - Triage a smart contract before an agent interacts with it: verified Solidity source, heuristic vulnerability scan, known-address check, function-selector resolution, and a read-only dry-run of the exact call you plan to make.
Related tools
Calldata decoder (ABI or selector DB)
POST /api/calldata-decodeDecode EVM smart-contract transaction calldata into the function name and typed parameters. Supply an ABI (from /api/con…
Gas snapshot (slow / standard / fast)
POST /api/gas-snapshotLive gas price snapshot for a chain - slow / standard / fast tiers in gwei, plus the latest base fee. Sampled from eth_f…
Transaction receipt (decoded transfers)
POST /api/tx-receiptFull receipt for a transaction hash in one call: status, block, from/to, value, gas used vs limit, effective gas price, …
Block info
GET /api/block-infoHeader-level detail for one block on Ethereum, Base, Polygon, Arbitrum, or Optimism: hash, timestamp (unix + ISO), trans…
Block receipts (one block, summarised)
POST /api/block-receiptsEvery transaction receipt in one block, fetched as a single upstream read and summarised: tx count, succeeded vs failed,…
Chain info snapshot
GET /api/chain-infoOne-call chain state snapshot: chain id, latest block number, and current gas price (wei + gwei) for Ethereum, Base, Pol…