For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_getBlockByHash - Tron

Example code for the eth_getBlockByHash JSON_RPC method. Complete guide on how to use eth_getBlockByHash JSON_RPC method in GetBlock Web3 documentation.

This method returns information about a block by its hash. The second parameter selects full transaction objects or transaction hashes.

Parameters

Parameter
Type
Required
Description

blockHash

string

Yes

32-byte block hash

fullTransactions

boolean

Yes

true for full transaction objects, false for hashes

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getBlockByHash",
    "params": ["0x0000000002f3a5b0f6d2e6c9a1b4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8", false],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc', {
    jsonrpc: '2.0',
    method: 'eth_getBlockByHash',
    params: ["0x0000000002f3a5b0f6d2e6c9a1b4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8", false],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);
example.py
import requests

response = requests.post(
    'https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'eth_getBlockByHash',
        'params': ["0x0000000002f3a5b0f6d2e6c9a1b4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8", false],
        'id': 'getblock.io'
    }
)

print(response.json())

Response

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "number": "0x40d2a00",
        "hash": "0x0000000002f3a5b0f6d2e6c9a1b4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8",
        "parentHash": "0x0000000002f3a5af...",
        "timestamp": "0x6675a2c0",
        "transactions": [
            "0xd5ec749ecc2a615399d8a6c864ea4c74ff9f523c2be0e341ac9be5d47d7c2d62"
        ],
        "size": "0x2a1f"
    }
}

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC protocol version ("2.0")

id

string

Request identifier matching the request

result

object

Block object, or null if the block does not exist

Result Object

Field
Type
Description

number

string

Block number, hex-encoded

hash

string

Block hash

timestamp

string

Block time in seconds, hex-encoded

transactions

array

Transaction hashes, or full objects when requested

Use Cases

  • Hash Lookups: Fetch a block when only its hash is known

  • Verification: Confirm a block's contents against its hash

  • Explorer Links: Resolve a block-hash link to block detail

  • Indexing: Read a block found by hash

Error Handling

Error Code
Message
Description

-32602

Invalid params

A parameter is missing or has the wrong type or format

-32603

Internal error

The node failed to process the request

Was this helpful?