eth_getBlockByNumber - SEI
Example code for the eth_getBlockByNumber JSON-RPC method. Complete guide on how to use eth_getBlockByNumber JSON-RPC in GetBlock Web3 documentation
Parameters
Parameter
Type
Description
Request
curl --location 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", true],
"id": "getblock.io"
}'import axios from 'axios';
const url = 'https://go.getblock.io/<ACCESS-TOKEN>/';
const payload = {
jsonrpc: '2.0',
method: 'eth_getBlockByNumber',
params: ["latest", true],
id: 'getblock.io'
};
axios.post(url, payload, {
headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"number": "0x4B8F2A1",
"hash": "0x9a5e2b3c...",
"parentHash": "0x8b4d1a2b...",
"timestamp": "0x65f4a1b2",
"gasLimit": "0x1c9c380",
"gasUsed": "0x5208",
"transactions": [...]
}
}Response Parameters
Field
Type
Description
Use Case
Error Handling
Error Code
Message
Description
Web3 Integration
Last updated
Was this helpful?