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 the openchain.xyz signature database with 4byte.directory as fallback. Send POST /api/selector-lookup with the required field selector and pay $0.002 per call over x402 or MPP (there is no free tier). It returns a JSON object with selector, kind, found, signatures and source.
Unknown selectors return {found:false} with an empty list, not an error.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
selector | string | yes | 0x-prefixed 4-byte function selector (10 chars) or 32-byte event topic hash (66 chars). |
Example request
curl -i -X POST https://agent402.tools/api/selector-lookup \
-H "Content-Type: application/json" \
-d '{"selector":"0xa9059cbb"}'
Without payment this returns HTTP 402 Payment Required with the exact price for selector-lookup; any x402 v2 or MPP client pays it and retries.
Example response
{
"selector": "0xa9059cbb",
"kind": "function",
"found": true,
"signatures": [
"transfer(address,uint256)"
],
"source": "openchain.xyz"
}
| Field | Type | Always present | In the example |
|---|---|---|---|
selector | string | yes | 0xa9059cbb |
kind | string | yes | function |
found | boolean | yes | true |
signatures | array of string | yes | 1 item in the example |
source | string | yes | openchain.xyz |
From an MCP client
catalog.call {
"slug": "selector-lookup",
"params": {
"selector": "0xa9059cbb"
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for selector-lookup; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
selectoris 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/selector-lookup 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/selector-lookup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"selector": "0xa9059cbb"
}),
});
Part of these workflows
Function selector / event topic lookup is one step in these 2 skill packs, 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.
- Transaction forensics - Explain what an EVM transaction actually did: confirmation status, the raw transaction from the chain, decoded calldata with typed parameters, the resolved function signature, and labeled counterparties.
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…
Verified contract ABI (Sourcify)
POST /api/contract-abiFetch the verified ABI for a contract address from Sourcify, plus a ready-to-use list of human-readable function signatu…
Verified contract source (Sourcify)
POST /api/contract-sourceFetch the verified Solidity source files and compiler metadata for a contract address from Sourcify's open verification …
Contract event logs
POST /api/event-logsFetch contract event logs (eth_getLogs) on Ethereum, Base, Polygon, Arbitrum, or Optimism - bounded so it always answers…
Solidity heuristic pattern scan
POST /api/solidity-scanDeterministic static pattern scan of Solidity smart-contract source text - a fixed ruleset flagging tx.origin authentica…
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 …