eth_getBlockByHash - Somnia
Example code for the eth_getBlockByHash JSON-RPC method. Complete guide on how to use eth_getBlockByHash JSON-RPC in GetBlock Web3 documentation.
This method returns information about a block by its hash on the Somnia network. This is useful for retrieving specific block data when you have the block hash, particularly for verifying block content and transaction inclusion.
Parameters
blockHash
string
Yes
32-byte block hash
fullTransactions
boolean
Yes
If true, returns full transaction objects; if false, returns transaction hashes
Request Example
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "getblock.io",
"method": "eth_getBlockByHash",
"params": [
"0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd",
false
]
}'const axios = require('axios');
const url = 'https://go.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
id: 'getblock.io',
method: 'eth_getBlockByHash',
params: ['0x4e3a3754410177e6937ef1f84bba68ea139e8d1a2258c5f85db9f1cd715a1bdd', false]
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response Example
Response Parameters
number
string
Block number in hex
hash
string
32-byte block hash
parentHash
string
32-byte parent hash
timestamp
string
Unix timestamp
gasLimit
string
Block gas limit
gasUsed
string
Total gas used
transactions
array
Transaction data
Use Cases
Verify block content by hash
Fetch block for transaction verification
Build block explorers
Verify transaction inclusion proofs
Historical data analysis
Error Handling
-32602
Invalid params - malformed hash
-32603
Internal error - node processing issues
null result
Block not found
SDK Integration
Last updated
Was this helpful?