Docs
Supported ChainsXDC NetworkJSON-RPC APIAccount Methods

eth_getCode - XDC Network RPC Method

Get contract bytecode on XDC Network. Essential for verifying smart contracts for tokenized trade finance (Letters of Credit, Bills of Lading), cross-border payments, and real-world asset tokenization.

Returns the bytecode at a given address on XDC Network.

Why XDC Network? Build on the enterprise-grade blockchain for trade finance with 2-second finality and ISO 20022 compliance with ISO 20022 messaging, ITFA membership, Contour Network acquisition, 801M+ transactions, and partnerships with Circle and Deutsche Telekom.

Use Cases

The eth_getCode method is essential for:

  • Contract verification - Check if address is a contract
  • Security analysis - Verify deployed bytecode matches expected
  • DeFi integrations - Validate contracts before interactions
  • Protocol analysis - Analyze contract deployments for tokenized trade finance (Letters of Credit, Bills of Lading), cross-border payments, and real-world asset tokenization

Request Parameters

Request
addressDATA

20-byte address

blockParameterQUANTITY|TAG

Block number or tag

Response Body

Response
resultDATA

Contract bytecode or 0x if EOA

Code Examples

Bash
curl -X POST https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_getCode",
    "params": [
      "0x951857744785E80e2De051c32EE7b25f9c458C42",
      "latest"
    ],
    "id": 1
  }'
JavaScript
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY');

const address = '0x951857744785E80e2De051c32EE7b25f9c458C42';
const code = await provider.getCode(address);

if (code === '0x') {
  console.log('Address is an EOA (externally owned account)');
} else {
  console.log('Address is a contract');
  console.log('Bytecode length:', code.length);
}

// Check if address is a contract
async function isContract(address) {
  const code = await provider.getCode(address);
  return code !== '0x';
}
Python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY'))

address = '0x951857744785E80e2De051c32EE7b25f9c458C42'
code = w3.eth.get_code(address)

if code == b'':
    print('Address is an EOA')
else:
    print('Address is a contract')
    print(f'Bytecode length: {len(code.hex())}')

# Check if address is a contract
def is_contract(address):
    code = w3.eth.get_code(address)
    return code != b''
Go
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, err := ethclient.Dial("https://api-xdc-mainnet.n.dwellir.com/YOUR_API_KEY")
    if err != nil {
        log.Fatal(err)
    }

    address := common.HexToAddress("0x951857744785E80e2De051c32EE7b25f9c458C42")
    code, err := client.CodeAt(context.Background(), address, nil)
    if err != nil {
        log.Fatal(err)
    }

    if len(code) == 0 {
        fmt.Println("Address is an EOA")
    } else {
        fmt.Printf("Contract bytecode length: %d\n", len(code))
    }
}

On this page