Skip to main content

eth_getCode

Retrieves the compiled bytecode of a smart contract deployed on the Celo network. This method is essential for contract verification, security analysis, and understanding deployed contract functionality on Celo's mobile-first blockchain infrastructure.

Parameters​

ParameterTypeRequiredDescription
addressstringYesThe 20-byte address of the contract (0x-prefixed hex string)
blockNumber/blockTagstringYesBlock number in hex (e.g., "0x1b4") or block tag: "latest", "earliest", "pending", "safe", "finalized"

Block Tags​

  • latest - Most recent block in the canonical chain
  • earliest - Genesis block
  • pending - Pending state/transactions
  • safe - Latest safe head block (Celo)
  • finalized - Latest finalized block (Celo)

Returns​

Returns the bytecode as a hex-encoded string. For Externally Owned Accounts (EOAs), returns "0x".

TypeDescription
stringHex-encoded bytecode starting with "0x". Returns "0x" for EOA addresses

Code Examples​

# Get bytecode for USDC contract on Celo
curl -X POST https://api-celo-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"latest"
],
"id": 1
}'

Response Example​

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

Important Notes​

EOA vs Contract Addresses​

  • Contract addresses: Return the actual bytecode of the deployed smart contract
  • EOA addresses: Return "0x" as they contain no contract code
  • Use this method to programmatically distinguish between EOAs and contracts

Use Cases​

  • Contract verification: Compare deployed bytecode with source code
  • Security analysis: Analyze contract functionality and potential vulnerabilities
  • Proxy detection: Identify proxy contracts and their implementation patterns
  • Contract interaction: Understand contract capabilities before interaction

Celo-Specific Considerations​

  • Celo is a mobile-first, EVM-compatible blockchain with proof-of-stake consensus
  • Bytecode format is identical to Ethereum mainnet
  • Gas costs for contract deployment and execution are significantly lower
  • Full compatibility with Ethereum smart contracts and tooling

Need help? Contact our support team or check the Celo documentation.