Docs
Supported ChainsXDC NetworkJSON-RPC APIBlock Methods

eth_getBlockByNumber - XDC Network RPC Method

Retrieve complete block data by block number on XDC Network. Perfect for trade finance developers, enterprise blockchain teams, and RWA tokenization builders building on the enterprise-grade blockchain for trade finance with 2-second finality and ISO 20022 compliance.

Returns information about a block by block number 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_getBlockByNumber method is essential for:

  • Block explorers - Display complete block information
  • Transaction indexers - Process all transactions in a block
  • Analytics platforms - Analyze blockchain data for tokenized trade finance (Letters of Credit, Bills of Lading), cross-border payments, and real-world asset tokenization
  • Timestamp verification - Get block timestamps for time-based logic

Request Parameters

Request
blockNumberQUANTITY|TAG

Block number in hex, or "latest", "earliest", "pending", "safe", "finalized"

fullTransactionsBoolean

If true, returns full transaction objects; if false, returns transaction hashes

Response Body

Response
numberQUANTITY

Block number

hashDATA

32-byte block hash

parentHashDATA

32-byte parent block hash

timestampQUANTITY

Unix timestamp

gasUsedQUANTITY

Total gas used by all transactions

gasLimitQUANTITY

Maximum gas allowed in block

transactionsArray

Array of transaction objects or hashes

baseFeePerGasQUANTITY

Base fee per gas (EIP-1559)

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_getBlockByNumber",
    "params": ["latest", false],
    "id": 1
  }'
JavaScript
import { JsonRpcProvider } from 'ethers';

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

// Get latest block
const block = await provider.getBlock('latest');
console.log('Block number:', block.number);
console.log('Timestamp:', new Date(block.timestamp * 1000));
console.log('Transactions:', block.transactions.length);

// Get block with full transactions
const blockWithTxs = await provider.getBlock('latest', true);
for (const tx of blockWithTxs.prefetchedTransactions) {
  console.log('Transaction:', tx.hash);
}
Python
from web3 import Web3

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

# Get latest block
block = w3.eth.get_block('latest')
print(f'Block number: {block.number}')
print(f'Timestamp: {block.timestamp}')
print(f'Transactions: {len(block.transactions)}')

# Get block with full transactions
block_full = w3.eth.get_block('latest', full_transactions=True)
for tx in block_full.transactions:
    print(f'Transaction: {tx.hash.hex()}')
Go
package main

import (
    "context"
    "fmt"
    "log"
    "math/big"

    "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)
    }

    // Get latest block
    block, err := client.BlockByNumber(context.Background(), nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Block number: %d\n", block.Number().Uint64())
    fmt.Printf("Timestamp: %d\n", block.Time())
    fmt.Printf("Transactions: %d\n", len(block.Transactions()))
}

Error Handling

Error CodeMessageDescription
-32602Invalid paramsInvalid block number or parameter format
-32000Block not foundBlock does not exist