POST
/
evm
eth_getBlockByNumber
curl --request POST \
  --url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByNumber",
  "params": [
    "0x9d0c37",
    false
  ],
  "id": 1
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "number": "0x9d0c37",
    "hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "parentHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
    "timestamp": "0x61bc8c3a",
    "gasLimit": "0x1c9c380",
    "gasUsed": "0x5208",
    "transactions": [
      "0xabc123...",
      "0xdef456..."
    ],
    "miner": "0x0000000000000000000000000000000000000000",
    "difficulty": "0x0",
    "totalDifficulty": "0x0",
    "size": "0x220",
    "extraData": "0x"
  }
}
The eth_getBlockByNumber JSON-RPC method returns information about a block by its number. This method is essential for retrieving block data when you know the block number, commonly used for sequential block processing, blockchain synchronization, and historical data analysis.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

The method takes two parameters:
  1. Block number - The number of the block to retrieve
  2. Full transaction objects - Whether to return full transaction objects or just hashes

Parameter details

  • blockNumber (string, required) — Block identifier: "latest", "earliest", "pending", or a specific block number in hexadecimal
  • fullTransactionObjects (boolean, required) — If true, returns full transaction objects; if false, returns only transaction hashes

Response

The method returns detailed information about the specified block, or null if the block is not found.

Response structure

Block object:
  • number — Block number as a hexadecimal string
  • hash — The 32-byte hash of the block
  • parentHash — Hash of the parent block
  • timestamp — Block timestamp as a Unix timestamp in hexadecimal
  • gasLimit — Maximum gas allowed in this block
  • gasUsed — Total gas used by all transactions in the block
  • transactions — Array of transaction hashes or full transaction objects
  • miner — Address of the block miner/validator
  • difficulty — Block difficulty (may be 0 for some consensus mechanisms)
  • totalDifficulty — Total difficulty of the chain until this block
  • size — Block size in bytes as a hexadecimal string
  • extraData — Extra data field of the block
  • nonce — Block nonce (if applicable)
  • receiptsRoot — Root hash of the receipts trie
  • stateRoot — Root hash of the state trie
  • transactionsRoot — Root hash of the transactions trie

Block number formats

Special identifiers:
  • "latest" — Most recent block
  • "earliest" — Genesis block (block 0)
  • "pending" — Pending block being mined
Hexadecimal numbers:
  • "0x0" — Genesis block
  • "0x1" — Block 1
  • "0x9d0c37" — Block 10,291,255 (decimal)

Usage example

Basic implementation

// Get block information by number on Hyperliquid
const getBlockByNumber = async (blockNumber, fullTransactionObjects = false) => {
  const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_getBlockByNumber',
      params: [blockNumber, fullTransactionObjects],
      id: 1
    })
  });
  
  const data = await response.json();
  return data.result;
};

// Get latest block
const getLatestBlock = async () => {
  const block = await getBlockByNumber('latest', false);
  
  if (!block) {
    throw new Error('Latest block not found');
  }
  
  return {
    number: parseInt(block.number, 16),
    hash: block.hash,
    timestamp: new Date(parseInt(block.timestamp, 16) * 1000),
    gasUsed: parseInt(block.gasUsed, 16),
    gasLimit: parseInt(block.gasLimit, 16),
    transactionCount: block.transactions.length,
    utilization: (parseInt(block.gasUsed, 16) / parseInt(block.gasLimit, 16)) * 100
  };
};

// Process a range of blocks
const processBlockRange = async (startBlock, endBlock) => {
  const blocks = [];
  
  for (let i = startBlock; i <= endBlock; i++) {
    const hexBlock = "0x" + i.toString(16);
    try {
      const block = await getBlockByNumber(hexBlock, false);
      if (block) {
        blocks.push({
          number: parseInt(block.number, 16),
          hash: block.hash,
          transactionCount: block.transactions.length,
          gasUsed: parseInt(block.gasUsed, 16)
        });
      }
    } catch (error) {
      console.error(`Error processing block ${i}:`, error);
    }
  }
  
  return blocks;
};

// Usage examples
getLatestBlock()
  .then(block => console.log('Latest Block:', block))
  .catch(error => console.error('Error:', error));

// Process blocks 100-110
processBlockRange(100, 110)
  .then(blocks => console.log('Block Range:', blocks))
  .catch(error => console.error('Error:', error));

Hyperliquid-specific considerations

System transactions

HyperCore transactions:
  • Blocks may contain system transactions that originate from HyperCore
  • Use eth_getSystemTxsByBlockNumber to retrieve system transactions specifically
  • System transactions are separate from regular user transactions
  • Important for complete block analysis and understanding network activity

Block processing

Sequential access:
  • Process blocks sequentially for complete chain analysis
  • Handle missing blocks gracefully in case of gaps
  • Use block numbers for efficient sequential processing
  • Track last processed block for incremental updates
Block number formats:
  • "latest" — Most recent block
  • "earliest" — Genesis block (block 0)
  • "0x1a4" — Specific block number in hexadecimal (420 in decimal)

Example request

Shell
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x9d0c37",false],"id":1}' \
  https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm

Use cases

The eth_getBlockByNumber method is essential for applications that need to:
  • Blockchain synchronization: Download and process blocks sequentially
  • Block explorers: Display block information and enable navigation
  • Analytics platforms: Collect block data for network analysis
  • Transaction monitoring: Track transactions within specific blocks
  • Historical analysis: Study past blockchain states and events
  • Audit systems: Verify blockchain integrity and transaction history
  • Development tools: Debug and test blockchain applications
  • System transaction analysis: Analyze both regular and HyperCore system transactions
  • Network monitoring: Track block production and network health
  • Integration services: Provide block data to external systems
Block numbers are sequential. If a block number doesn’t exist (e.g., future block), the method returns null. On Hyperliquid, blocks may contain system transactions from HyperCore - use eth_getSystemTxsByBlockNumber to retrieve these separately.

Body

application/json

Response

200 - application/json

Successful response with block information

The response is of type object.