For DevelopersGX EVMRaw EVM Block Data

Raw EVM Block Data

This page documents how to access raw block data from the GX EVM, including block headers, transaction receipts, and event logs.

Accessing Block Data

Use standard Ethereum JSON-RPC methods to query block data from the GX EVM RPC endpoint.

Get Latest Block

import { ethers } from "ethers";
 
const provider = new ethers.JsonRpcProvider("https://rpc.gx.exchange");
 
const block = await provider.getBlock("latest");
console.log("Block number:", block.number);
console.log("Timestamp:", block.timestamp);
console.log("Gas limit:", block.gasLimit.toString());
console.log("Gas used:", block.gasUsed.toString());
console.log("Transaction count:", block.transactions.length);
from web3 import Web3
 
w3 = Web3(Web3.HTTPProvider("https://rpc.gx.exchange"))
 
block = w3.eth.get_block("latest")
print(f"Block number: {block.number}")
print(f"Timestamp: {block.timestamp}")
print(f"Gas limit: {block.gasLimit}")
print(f"Transactions: {len(block.transactions)}")

Get Block with Full Transactions

const block = await provider.getBlock("latest", true);
for (const tx of block.prefetchedTransactions) {
  console.log(`${tx.hash}: from=${tx.from} to=${tx.to} value=${tx.value}`);
}

Get Block by Number

const block = await provider.getBlock(1000);

Get Block by Hash

const block = await provider.getBlock("0xabc123...");

Block Header Fields

FieldTypeDescription
numberintSequential block number
hashhexBlock hash (32 bytes)
parentHashhexParent block hash
timestampintUnix timestamp (seconds)
gasLimitintGas limit (2M for fast, 30M for slow blocks)
gasUsedintTotal gas consumed by all transactions
baseFeePerGasintEIP-1559 base fee in wei
mineraddressValidator address
transactionsRoothexMerkle root of transactions
stateRoothexState trie root hash
receiptsRoothexReceipts trie root hash
logsBloomhexBloom filter for log topics
extraDatahexValidator-provided extra data

Transaction Receipts

const receipt = await provider.getTransactionReceipt("0xTxHash...");
console.log("Status:", receipt.status);        // 1 = success, 0 = revert
console.log("Gas used:", receipt.gasUsed);
console.log("Block:", receipt.blockNumber);
console.log("Logs:", receipt.logs.length);

Receipt Fields

FieldTypeDescription
statusint1 for success, 0 for revert
transactionHashhexTransaction hash
blockNumberintBlock containing this transaction
blockHashhexBlock hash
gasUsedintGas consumed
effectiveGasPriceintActual gas price paid
logsArrayEvent logs emitted
contractAddressaddress?Set if this was a contract creation

Event Logs

Querying Logs by Block Range

const logs = await provider.getLogs({
  fromBlock: 1000,
  toBlock: 1100,
  address: "0xContractAddress...",
  topics: [ethers.id("Transfer(address,address,uint256)")],
});
 
for (const log of logs) {
  console.log("Block:", log.blockNumber);
  console.log("Data:", log.data);
  console.log("Topics:", log.topics);
}
logs = w3.eth.get_logs({
    "fromBlock": 1000,
    "toBlock": 1100,
    "address": "0xContractAddress...",
    "topics": [w3.keccak(text="Transfer(address,address,uint256)")],
})
 
for log in logs:
    print(f"Block {log.blockNumber}: {log.data.hex()}")

Log Query Limits

ParameterLimit
Maximum block range10,000 blocks
Maximum results per query10,000 logs

For larger ranges, paginate by breaking the range into smaller chunks.

Streaming New Blocks

Use WebSocket subscriptions for real-time block data:

const wsProvider = new ethers.WebSocketProvider("wss://rpc.gx.exchange/ws");
 
wsProvider.on("block", async (blockNumber) => {
  const block = await wsProvider.getBlock(blockNumber);
  console.log(`New block ${blockNumber}: ${block.transactions.length} txs`);
});

Data Archival

The GX EVM RPC endpoint retains full historical block data. There is no pruning of old blocks. You can query any block from genesis to the current height.

For high-volume data ingestion, consider running a non-validating node to access block data locally without rate limits.