Skip to main content

eth_getBlockByHash

Returns information about a block by hash on Moonbase Alpha.

Why Moonbase? Build on the Moonbeam testnet for risk-free EVM dApp development and deployment testing with free testnet tokens, full EVM compatibility, XCM testing capabilities, and identical feature set to Moonbeam mainnet.

Use Cases#

The eth_getBlockByHash method is essential for:

  • Block verification - Verify block data using its unique hash
  • Chain reorganization handling - Track blocks during reorgs
  • Cross-chain bridges - Verify block finality for EVM dApp testing, XCM integration validation, and pre-mainnet deployment verification
  • Deterministic queries - Get consistent block data regardless of chain state

Parameters#

ParameterTypeRequiredDescription
blockHashDATAYes32-byte block hash
fullTransactionsBooleanYesIf true, returns full transaction objects; if false, returns transaction hashes

Request#

{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3",
false
],
"id": 1
}

Returns#

Returns the same block object as eth_getBlockByNumber, or null if no block is found.

FieldTypeDescription
numberQUANTITYBlock number
hashDATA32-byte block hash
parentHashDATA32-byte parent block hash
timestampQUANTITYUnix timestamp
gasUsedQUANTITYTotal gas used
transactionsArrayTransaction objects or hashes

Code Examples#

curl -X POST https://api-moonbase-alpha.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3",
false
],
"id": 1
}'

Error Handling#

Error CodeMessageDescription
-32602Invalid paramsInvalid block hash format
-32000Block not foundBlock with this hash does not exist