eth_getBlockByHash
Retrieves comprehensive information about a block on IoTeX L2 by its hash identifier, including header data, transaction lists, and execution metrics.
Parameters​
Parameter | Type | Required | Description |
---|---|---|---|
blockHash | string | Yes | The 32-byte block hash (66 characters with 0x prefix) |
fullTransactionObjects | boolean | Yes | When true , returns complete transaction objects. When false , returns only transaction hashes |
Returns​
Returns a block object with the following fields:
Field | Type | Description |
---|---|---|
number | string | Block number in hexadecimal |
hash | string | 32-byte block hash |
parentHash | string | Hash of the parent block |
mixHash | string | Unique identifier for block generation |
nonce | string | Proof-of-work nonce (always 0x0000000000000000 on IoTeX L2) |
sha3Uncles | string | SHA3 hash of uncles data |
logsBloom | string | 256-byte bloom filter for block logs |
transactionsRoot | string | Root hash of the transaction trie |
stateRoot | string | Root hash of the final state trie |
receiptsRoot | string | Root hash of the receipts trie |
miner | string | Address receiving block rewards |
difficulty | string | Block difficulty (minimal on IoTeX L2) |
totalDifficulty | string | Total chain difficulty up to this block |
extraData | string | Additional block-specific data |
size | string | Block size in bytes (hexadecimal) |
gasLimit | string | Maximum gas allowed in block |
gasUsed | string | Total gas consumed by all transactions |
timestamp | string | Unix timestamp of block creation |
transactions | array | Array of transaction hashes or full transaction objects |
uncles | array | Array of uncle block hashes (always empty on IoTeX L2) |
baseFeePerGas | string | Base fee per gas unit (EIP-1559) |
l1BlockNumber | string | Corresponding L1 block number (IoTeX-specific) |
sendCount | string | Number of L2-to-L1 messages (IoTeX-specific) |
sendRoot | string | Root hash of L2-to-L1 message tree (IoTeX-specific) |
Implementation Example​
- cURL
- JavaScript
- Python
curl -X POST https://api-iotex-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382",
false
],
"id": 1
}'
const response = await fetch('https://api-iotex-mainnet.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBlockByHash',
params: [
'0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382',
false // Set to true for full transaction objects
],
id: 1
})
});
const data = await response.json();
console.log(data.result);
import requests
import json
url = 'https://api-iotex-mainnet.n.dwellir.com/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382",
False # Set to True for full transaction objects
],
"id": 1
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.json()['result'])
Response Example​
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"baseFeePerGas": "0x5f5e100",
"difficulty": "0x1",
"extraData": "0x",
"gasLimit": "0x7a1200",
"gasUsed": "0x5208",
"hash": "0x7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382",
"l1BlockNumber": "0x8e1a23",
"logsBloom": "0x00000000000000000000000000000000...",
"miner": "0x0000000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"number": "0x5bad55",
"parentHash": "0xb4fbadf8ea452b139718e2700dc1135cfc81145031c84b7ab27cd99f43ec28ca",
"receiptsRoot": "0x9b0816dba2e4c1c7b2d38d0c3da6e6bb93c1713a7e986e38f856b6fb725234cf",
"sendCount": "0x2",
"sendRoot": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x21d",
"stateRoot": "0xddc8b0234248b014296fed29c5c0e9d6e5a6e4a0576ce66970a36c064e3cd96b",
"timestamp": "0x5e0be0ff",
"totalDifficulty": "0x1",
"transactions": [
"0x5d2dd8b32dc30f347120c5877975c93ccf3e5a5c9ad0c595b0a73c3e00c9e9bb",
"0x8a91b1b37e0e463c27cb340dc0e2cbc5636cba8d9b3e9a66c2a9e6c3f8c65e82"
],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
Need help? Contact our support team or check the IoTeX documentation.