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.

GET/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>"
Parameters
ParameterDescription
function

query · string · required

The function signature, types only, e.g. balanceOf(address) or name().
args

query · 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.
returns

query · string · optional

The return types, e.g. uint256 or uint112,uint112,uint32. Omit to get the raw bytes only.
chain

path · 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.
address

path · 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.

Response fields of Call a read-only contract function
FieldTypeDescription
addressstringThe contract, lowercase.
functionstringThe signature called, in canonical form (uint becomes uint256).
selectorstringThe four-byte selector of that signature.
outcomestringWhat the call did — see the endpoint description.
returnDatastring | nullThe raw bytes returned, lowercase hex; "0x" when none; null on a revert.
valuesobject[] | nullThe decoded return values, in order. null unless outcome is returned and you gave return types.
values[].typestringThe return type, canonical.
values[].valuestring | booleanIntegers as decimal strings, addresses and bytes as lowercase hex, bools as booleans.
revertDatastring | nullOn a revert, the bytes the contract reverted with when the chain reports them ("0x": none); else null.
revertReasonstring | nullOn 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