eth_getCode

Network: BSC · Mainnet · Chain ID 56 (0x38)

Counts as 1 request. See Request Counting.

Returns code at a given address. Used to check if an address is a smart contract.

Parameters

  1. DATA (20 bytes) — Address to get code from.
  2. QUANTITY|TAG — Block number, or "latest", "earliest", "pending".

Returns

DATA — The code from the given address. Returns 0x for EOA (non-contract) accounts.

Request

{ "jsonrpc": "2.0", "method": "eth_getCode", "params": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "latest"], "id": 1 }

Response

{ "jsonrpc": "2.0", "id": 1, "result": "0x6080604052..." }

Replace the example address with a contract on BSC.

If the result is "0x", the address is an EOA (externally owned account), not a contract.

Code Examples

curl -X POST https://bsc-rpc.blockreq.com/v1/rpc/public \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","latest"],"id":1}'

Try It