Coinbase Wallet SDK
eth_getCode
Get the bytecode at a given address
Defined in the Ethereum JSON-RPC Specification
Returns the bytecode at a given address. This is useful for verifying if an address is a contract or an externally owned account.
Parameters
The address to get bytecode from (20 bytes).
Integer block number, or the string “latest”, “earliest” or “pending”.
Returns
The bytecode at the given address as a hexadecimal string. Returns “0x” for externally owned accounts.
Error Handling
Code | Message | Description |
---|---|---|
-32602 | Invalid address or block parameter | The provided address or block parameter is invalid |
4100 | Requested method not supported | The method is not supported by the wallet |
If the result is “0x”, the address is an externally owned account (EOA). If it contains bytecode, it’s a smart contract.