eth_getCode
JSON-RPC method returns the bytecode of a smart contract at a given address and block. This method is essential for contract verification, analysis, and determining whether an address contains a smart contract or is an externally owned account (EOA).
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
The method takes two parameters:- Address - The contract address to retrieve bytecode from
- Block parameter - The block at which to retrieve the code
Parameter details
address
(string, required) — The 20-byte address to retrieve code fromblock
(string, required) — Block identifier:"latest"
(only the latest block is supported on Hyperliquid)
Response
The method returns the contract bytecode as a hexadecimal string, or"0x"
if no code exists at the address.
Hyperliquid-specific considerations
Block limitations
Latest block only:- Only the
"latest"
block parameter is supported - Historical contract code queries are not available in the default implementation
- All code retrieval is performed against the current state
- For historical analysis, consider using archive node implementations
Contract analysis
Address classification:- Distinguish between contracts and EOAs efficiently
"0x"
indicates an externally owned account (EOA)- Non-empty bytecode indicates a smart contract
- Use for implementing different handling logic for different address types
Example request
This an example call with wrapped HYPE (wHYPE) on the Hyperliquid mainnet deployed at 0x5555555555555555555555555555555555555555.Shell
Use cases
Theeth_getCode
method is essential for applications that need to:
- Address classification: Distinguish between smart contracts and EOAs
- Contract verification: Verify deployed contracts against expected bytecode
- Security analysis: Analyze contract bytecode for security patterns
- Block explorers: Display contract information and verification status
- Development tools: Build contract analysis and debugging tools
- Wallet applications: Verify contract authenticity before interactions
- DeFi protocols: Analyze and verify protocol contract implementations
- Integration services: Provide contract information to external systems
On Hyperliquid,
eth_getCode
only supports the latest block. The returned bytecode is the runtime code deployed on the blockchain, not the constructor code. For EOAs (externally owned accounts), this method returns "0x"
.Body
application/json