Contract event logs
POST /api/event-logsFetch contract event logs (eth_getLogs) on Ethereum, Base, Polygon, Arbitrum, or Optimism - bounded so it always answers: block range capped at 2000 blocks (default: the last 100, auto-narrowed for busy contracts), at most 200 logs returned (truncated flag set if more matched). Send POST /api/event-logs with the required field address and pay $0.003 per call over x402 or MPP (there is no free tier). It returns a JSON object with network, address, fromBlock, toBlock, count and 2 more.
Filter by contract address and optional topic0 (event signature hash). Keyless multi-endpoint failover.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
address | string | yes | Contract address to read logs from (0x…). Also accepted as addr, wallet, account. |
topic0 | string | no | Optional event signature hash (32-byte 0x hex), e.g. the ERC-20 Transfer topic. |
fromBlock | string | no | Start block (decimal or 0x hex). Default: toBlock - 100. |
toBlock | string | no | End block (decimal, 0x hex, or "latest"). Default latest. |
network | string | no | ethereum / base / polygon / arbitrum / optimism (default base). |
Example request
curl -i -X POST https://agent402.tools/api/event-logs \
-H "Content-Type: application/json" \
-d '{"address":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","topic0":"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","network":"base"}'
Without payment this returns HTTP 402 Payment Required with the exact price for event-logs; any x402 v2 or MPP client pays it and retries.
Example response
{
"network": "base",
"address": "0x8335…",
"fromBlock": 26999500,
"toBlock": 27000000,
"count": 87,
"truncated": false,
"logs": [
{
"blockNumber": 26999512,
"txHash": "0x…",
"topics": [
"0xddf2…"
],
"data": "0x…"
}
]
}
| Field | Type | Always present | In the example |
|---|---|---|---|
network | string | yes | base |
address | string | yes | 0x8335… |
fromBlock | number | yes | 26999500 |
toBlock | number | yes | 27000000 |
count | number | yes | 87 |
truncated | boolean | yes | false |
logs | array of objects | yes | 1 item in the example |
From an MCP client
catalog.call {
"slug": "event-logs",
"params": {
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"topic0": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"network": "base"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for event-logs; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
addressis 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/event-logs 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/event-logs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"topic0": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"network": "base"
}),
});
Related tools
Function selector / event topic lookup
POST /api/selector-lookupResolve a 4-byte function selector or a 32-byte event topic hash to its known human-readable Solidity signatures, via th…
Wallet token transfers (filtered)
POST /api/asset-transfersRecent token transfers for a wallet on Base, Ethereum and other EVM chains, newest first. Filtered transfer log for an E…
Block info
GET /api/block-infoHeader-level detail for one block on Ethereum, Base, Polygon, Arbitrum, or Optimism: hash, timestamp (unix + ISO), trans…
Latest block number
GET /api/block-numberThe latest block number on Ethereum, Base, Polygon, Arbitrum, or Optimism: returns network, blockNumber (integer) and he…
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…
Contract bytecode check
GET /api/contract-codeIs this address a contract, and what code does it hold? Returns isContract, deployed bytecode size, and the keccak-256 h…