Fantom
Fantom
eth_getCode
The eth_getCode method returns the compiled bytecode of a smart contract at a specified address. This essential method allows developers to verify contract implementations, perform security audits, and distinguish between regular accounts and smart contracts on the Ethereum blockchain.
Use Cases
- Smart contract verification and implementation checking
- Contract bytecode comparison and version validation
- Contract audit and security analysis workflows
- Differentiating between contracts and EOAs (Externally Owned Accounts)
- Contract implementation analysis for upgradeable systems
- Proxy contract verification and delegate implementation checks
- Detecting self-destructed contracts and contract existence
- Determining if an address is a token contract
- Smart contract reverse engineering and analysis
- Historical bytecode analysis across different blocks
Method Details
This method retrieves the EVM bytecode deployed at a specific address at the requested block height.
Response Example
Special Cases and Return Values
- Empty contract: Returns "0x" if no code exists at the address
- EOA address: Returns "0x" for regular wallet addresses (Externally Owned Accounts)
- Self-destructed contract: Returns "0x" after a contract has been destroyed via
selfdestruct - Pre-deployment: If checking a block before contract deployment, returns "0x"
- Standard contracts: Returns the full EVM bytecode for typical contracts
- Proxy contracts: Returns the proxy code, not the implementation code they delegate to
Identifying Contract Types
Different types of contracts have recognizable bytecode patterns:
- Proxy Contracts: Often contain delegate call operations
- ERC20 Tokens: Include transfer and approve functions
- ERC721 NFTs: Contain standard NFT interfaces
- Minimal Proxies (EIP-1167): Start with
0x363d3d37363d73... - Diamond Proxies (EIP-2535): Include facet management logic
- UUPS Proxies: Include upgrade functionality in implementation
Practical Example
Advanced Usage: Contract Type Detection
Common Contract Bytecode Prefixes
- 0x60806040: Common EVM bytecode prefix for Solidity contracts (version 0.4.x-0.8.x)
- 0x6080604052: Another common prefix for Solidity contracts
- 0x363d3d373d3d3d363d73: Common prefix for proxy contracts
- 0x363d3d37363d73: Common minimal proxy pattern (EIP-1167)
- 0x3d602d80600a3d3981f3: Another variation of minimal proxy
See also
- eth_getStorageAt - Returns the value from a specific storage position
- eth_call - Execute a read-only call to a contract
- eth_getBalance - Returns an account's ether balance
- eth_getProof - Generate proof of account and storage values
Parameters
The address of the smart contract
Block number in hex format or block tag