Skip to content

Transaction simulation (eth_call + gas)

$0.005 per callUSDC via x402POST /api/tx-simulate

Simulate a transaction before sending it: a dry run of a smart-contract call that executes eth_call and eth_estimateGas against the latest block over a keyless multi-endpoint public node pool. 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.

Category: Crypto & onchain dataTags: crypto simulation eth_call gas transaction evm dry-run smart-contract

Try in playground →

Parameters

NameTypeRequiredDescription
tostringyes0x-prefixed 40-char target contract/account address. Also accepted as target, dest, destination, end. The example sends 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.
datastringno0x-prefixed calldata (default 0x - plain value transfer).
fromstringnoOptional sender address (default zero address).
valuestringnoOptional value in wei - decimal string or 0x hex (default 0).
networkstringnoethereum / base / polygon / arbitrum / optimism (default base). The example sends 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.

Watch a call get paid

RequestPOST /api/tx-simulate
402$0.005 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example response

{
  "network": "base",
  "success": true,
  "returnData": "0x00000000000000000000000000000000000000000000000000000000000f4240",
  "gasEstimate": 31234,
  "revertReason": null
}
FieldTypeAlways presentIn the example
networkstringyesbase
successbooleanyestrue
returnDatastringyes0x00000000000000000000000000000000000000000000000000000000000f4240
gasEstimatenumberyes31234
revertReasonnullnonull

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 an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.17.1.

Errors and behavior

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?.({ maxAmountPerPayment: "$0.005" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_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"
  }),
});

No wallet yet? Fund a first one with USDC on Base, no ETH needed, or run npx -y agent402-mcp@0.17.1 wallet new to make one on this computer: it stores the key and prints the address and the config, never the key.

The quote (Python)

Standard library only: the 402 and the price its PAYMENT-REQUIRED header quotes on each chain. To pay from Python, sign it with any x402 client.

import base64, json, urllib.error, urllib.request

req = urllib.request.Request("https://agent402.tools/api/tx-simulate", method="POST", data="{\"network\":\"base\",\"to\":\"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913\",\"data\":\"0x70a08231000000000000000000000000abf4fabd7c416fb67202e5f9002389fc75e2a9d0\"}".encode(), headers={"Content-Type": "application/json"})
try:
    urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
    quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
    print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]])  # the price, per chain, in base units

Part of these workflows

Transaction simulation (eth_call + gas) is one step in this skill pack, each sold as a single call:

Related tools

Calldata decoder (ABI or selector DB)

$0.002POST /api/calldata-decode

Decode EVM smart-contract transaction calldata into the function name and typed parameters.

Gas snapshot (slow / standard / fast)

$0.001POST /api/gas-snapshot

Live gas price snapshot for a chain - slow / standard / fast tiers in gwei, plus the latest base fee.

Transaction receipt (decoded transfers)

$0.003POST /api/tx-receipt

Full receipt for a transaction hash in one call: status, block, from/to, value, gas used vs limit, effective gas price.

Block info

$0.001GET /api/block-info

Header-level detail for one block on Ethereum, Base, Polygon, Arbitrum One, or OP Mainnet: hash, timestamp (unix + ISO).

Block receipts (one block, summarized)

$0.005POST /api/block-receipts

Every transaction receipt in one block, fetched as a single upstream read and summarized: tx count, succeeded vs failed.

Chain info snapshot

$0.001GET /api/chain-info

Chain info in one call: chain id, gas price (wei and gwei) and the current block for Ethereum, Base, Polygon, Arbitrum.