Contracts API
Call a read-only contract function
Runs one view function of an EVM contract at the latest block, from its signature and arguments, and returns the decoded answer or the revert.
/api/external/contract-analysis/contract-read/{chain}/{address}What it returns
Runs one read-only (view) function of a contract against the latest block and returns what it answers, decoded when you give the return types. Supported types: address, bool, uint8–uint256, int8–int256, bytes1–bytes32, bytes and string; arrays and tuples return 400. outcome says what happened: returned (bytes came back), empty (no bytes at all — there is no contract at the address, or the function returns nothing; never read it as zero), mismatch (bytes came back that cannot be the return types you gave — check them) or reverted (the contract refused the call; revertReason carries its message when it gave one). Integers are decimal strings, so no precision is lost.
Chains
- BNB Chain BNB
- Ethereum ETH
- Stable STABLE
- Base BASE
- Robinhood Chain RHC
- Arc ARC
Request
Send your key in the x-dex-data-key header. Replace each <placeholder> with a real value.
curl -H "x-dex-data-key: $DEXDATA_API_KEY" \ "https://api.dexdata.io/api/external/contract-analysis/contract-read/BNB/<address>?function=<function>"
| Parameter | Description |
|---|---|
functionquery · string · required | The function signature, types only, e.g. balanceOf(address) or name(). |
argsquery · string · optional | The arguments, as a JSON array in signature order, e.g. ["0x28c6c06298d514db089934071355e5743bf21d60"]. Integers as decimal strings, bytes as 0x hex, bools as true/false. Omit for none. |
returnsquery · string · optional | The return types, e.g. uint256 or uint112,uint112,uint32. Omit to get the raw bytes only. |
chainpath · string · required | Ethereum, BNB, Base, Stable, Arc or RHC. SOL returns 400: Solana programs have no view functions. CELO, ARB, OP and SCROLL return 400 here. |
addresspath · string · required | The contract to call, 0x followed by 40 hexadecimal characters. |
Response fields
A JSON response. Every field is always present; null means the value could not be established, never zero.
| Field | Type | Description |
|---|---|---|
address | string | The contract, lowercase. |
function | string | The signature called, in canonical form (uint becomes uint256). |
selector | string | The four-byte selector of that signature. |
outcome | string | What the call did — see the endpoint description. |
returnData | string | null | The raw bytes returned, lowercase hex; "0x" when none; null on a revert. |
values | object[] | null | The decoded return values, in order. null unless outcome is returned and you gave return types. |
values[].type | string | The return type, canonical. |
values[].value | string | boolean | Integers as decimal strings, addresses and bytes as lowercase hex, bools as booleans. |
revertData | string | null | On a revert, the bytes the contract reverted with when the chain reports them ("0x": none); else null. |
revertReason | string | null | On a revert, the message the contract gave, when it gave one. |
Start building with DexData today
Sign in, create a key and make your first call in a minute. Free credits every month, and you only pay for calls that succeed.
Get a free API key