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​
Parameter | Type | Required | Description |
---|---|---|---|
address | string | Yes | The 20-byte address of the contract (0x-prefixed hex string) |
blockNumber/blockTag | string | Yes | Block number in hex (e.g., "0x1b4") or block tag: "latest", "earliest", "pending", "safe", "finalized" |
Block Tags​
latest
- Most recent block in the canonical chainearliest
- Genesis blockpending
- Pending state/transactionssafe
- 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".
Type | Description |
---|---|
string | Hex-encoded bytecode starting with "0x". Returns "0x" for EOA addresses |
Code Examples​
- cURL
- JavaScript
- Python
# 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
}'
// Get bytecode for Celo's official bridge contract
const response = await fetch('https://api-celo-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getCode',
params: [
'0x49048044D57e1C92A77f79988d21Fa8fAF74E97e',
'latest'
],
id: 1
})
});
const data = await response.json();
console.log('Contract bytecode:', data.result);
// Check if address is a contract or EOA
if (data.result === '0x') {
console.log('Address is an EOA (no contract code)');
} else {
console.log('Address contains contract code');
}
import requests
import json
# Get bytecode for a contract on Celo
url = "https://api-celo-mainnet.n.dwellir.com/YOUR_API_KEY"
payload = {
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x765DE816845861e75A25fCA122bb6898B8B1282a", # cUSD on Celo
"latest"
],
"id": 1
}
response = requests.post(url, json=payload)
result = response.json()
if result['result'] == '0x':
print("Address is an EOA")
else:
print(f"Contract bytecode: {result['result'][:100]}...") # First 100 chars
print(f"Bytecode length: {len(result['result'])} characters")
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.