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
| Field | Type | Description |
|---|---|---|
number | int | Sequential block number |
hash | hex | Block hash (32 bytes) |
parentHash | hex | Parent block hash |
timestamp | int | Unix timestamp (seconds) |
gasLimit | int | Gas limit (2M for fast, 30M for slow blocks) |
gasUsed | int | Total gas consumed by all transactions |
baseFeePerGas | int | EIP-1559 base fee in wei |
miner | address | Validator address |
transactionsRoot | hex | Merkle root of transactions |
stateRoot | hex | State trie root hash |
receiptsRoot | hex | Receipts trie root hash |
logsBloom | hex | Bloom filter for log topics |
extraData | hex | Validator-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
| Field | Type | Description |
|---|---|---|
status | int | 1 for success, 0 for revert |
transactionHash | hex | Transaction hash |
blockNumber | int | Block containing this transaction |
blockHash | hex | Block hash |
gasUsed | int | Gas consumed |
effectiveGasPrice | int | Actual gas price paid |
logs | Array | Event logs emitted |
contractAddress | address? | 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
| Parameter | Limit |
|---|---|
| Maximum block range | 10,000 blocks |
| Maximum results per query | 10,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.