eth_getBlockByHash - Mantle
This method returns information about a block on Mantle by block hash.
Parameters
| Parameter | Type | Description |
|---|---|---|
| blockHash | string | 32-byte hash of the block |
| fullTransactions | boolean | If true, returns full transaction objects; if false, returns transaction hashes |
Request
curl
bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e", false],
"id": "getblock.io"
}'example.js
javascriptimport axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e", false],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));example.py
pythonimport requests
import json
url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
payload = json.dumps({
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e", False],
"id": "getblock.io"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=payload)
print(response.text)main.rs
rustuse reqwest::header;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
.header(header::CONTENT_TYPE, "application/json")
.body(r#"{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e", false],
"id": "getblock.io"
}"#)
.send()
.await?;
println!("{}", response.text().await?);
Ok(())
}Response
response.json
json{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"difficulty": "0x2",
"extraData": "0xd98301090a846765746889676f312e31352e3133856c696e7578",
"gasLimit": "0xe4e1c0",
"gasUsed": "0x5208",
"hash": "0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e",
"logsBloom": "0x00000000...",
"miner": "0x0000000000000000000000000000000000000000",
"number": "0x3f6777",
"parentHash": "0xd9505c7d82fbbad090d3ab4b4ecd20bca0f3700ce0c0c5ad2563a4100f86a004",
"timestamp": "0x643fc8a5",
"transactions": [],
"uncles": []
}
}Response Parameters
| Field | Type | Description |
|---|---|---|
| number | string | Block number (hex) |
| hash | string | Block hash (32 bytes) |
| parentHash | string | Parent block hash |
| timestamp | string | Unix timestamp of block creation |
| gasLimit | string | Maximum gas allowed in block |
| gasUsed | string | Total gas used by transactions |
| transactions | array | Array of transaction hashes or objects |
Use Case
The eth_getBlockByHash method is essential for:
- Verifying block existence by hash
- Block explorer functionality
- Cross-referencing block data
- Transaction confirmation validation
- Historical block analysis
- Chain reorganization detection
Error Handling
| Status Code | Error Message | Cause |
|---|---|---|
| 403 | Forbidden | Missing or invalid ACCESS-TOKEN |
| -32602 | Invalid params | Invalid block hash format |
Web3 Integration
ethers.js
javascriptimport { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
const block = await provider.getBlock('0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e');
console.log('Block:', block);viem.js
javascriptimport { createPublicClient, http } from 'viem';
import { mantle } from 'viem/chains';
const client = createPublicClient({
chain: mantle,
transport: http('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/')
});
const block = await client.getBlock({
blockHash: '0x9b14d73f45c836bfb0e1f59453c39fe8cddab45a0f78670dc6190e5c85b65a8e'
});
console.log('Block:', block);