eth_getCode
Returns code at a given address.
Parameters
- Address - Address to get code from
- Block Parameter - Block number or "latest", "earliest", "pending"
{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "latest"],
"id": 1
}
Returns
DATA
- The code from the given address.
Implementation Examples
- cURL
- JavaScript
curl -X POST https://api-tron-jsonrpc.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "latest"],
"id": 1
}'
// Using ethers.js
const code = await provider.getCode('0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b');
const isContract = code !== '0x';
console.log('Is contract:', isContract);