eth_getBlockByNumber - Tron
Example code for the eth_getBlockByNumber JSON_RPC method. Complete guide on how to use eth_getBlockByNumber JSON_RPC method in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["0x40d2a00", false],
"id": "getblock.io"
}'const axios = require('axios');
const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc', {
jsonrpc: '2.0',
method: 'eth_getBlockByNumber',
params: ["0x40d2a00", false],
id: 'getblock.io'
}, {
headers: { 'Content-Type': 'application/json' }
});
console.log(response.data.result);import requests
response = requests.post(
'https://go.getblock.io/<ACCESS-TOKEN>/jsonrpc',
headers={'Content-Type': 'application/json'},
json={
'jsonrpc': '2.0',
'method': 'eth_getBlockByNumber',
'params': ["0x40d2a00", 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"
],
"gasLimit": "0x0",
"gasUsed": "0x0",
"size": "0x2a1f"
}
}Response Parameters
Parameter
Type
Description
Result Object
Field
Type
Description
Use Cases
Error Handling
Error Code
Message
Description
Was this helpful?