Skip to main content

Don't have an RPC Node yet?

Start using RPC Nodes in your project today.

Get your free RPC Node
Version: 2.2

eth_getBlockByHash

Get Block By Hash​

POSThttps://site1.moralis-nodes.com/:chain/:apiKey

Returns information about a block by hash. Optionally, it can also return the full transaction objects if the second parameter is set to true; otherwise, only the transaction hashes are returned.

Note

Please refer to RPC schema page for more details on the RPC params and RPC response definitions of the RPC method.

PATH PARAMS
chainstringrequired
The blockchain to interact with.
apiKeystringrequired
Your API key for authentication.
BODY PARAM
jsonrpcstringrequired
JSON-RPC version (typically 2.0).
idnumberrequired
The request identifier.
methodstringrequired
The JSON-RPC method being invoked.
paramsrpcArrayrequired
Parameters for the block query, including the block hash and a boolean indicating whether to return full transaction objects.
Responses
// Dependencies to install:
// $ npm install node-fetch --save
// add "type": "module" to package.json

import fetch from 'node-fetch';

const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "eth_getBlockByHash"
})
};

fetch('https://site1.moralis-nodes.com/eth/YOUR_API_KEY', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"number": "0x10d4f",
"hash": "0x18173058d45f8aa984181fdfbfece01a93a971ea63e008231b2e15f151e0903f",
"transactions": [
{
"blockHash": "0x18173058d45f8aa984181fdfbfece01a93a971ea63e008231b2e15f151e0903f",
"blockNumber": "0x15df",
"from": "0x354f3eD35Ae1a182aF933b793e49d3c86CFcDc63",
"to": "0x354f3eD35Ae1a182aF933b793e49d3c86CFcDc63"
}
],
"parentHash": "0xd584c5509e3a3d4b2d3bbde4c8e8c0adec7f5c560e9d42b8f12f3c039dd40e92",
"nonce": "0x0000000000000000",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000...",
"transactionsRoot": "0x3a1b2c...",
"stateRoot": "0xf1132b...",
"receiptsRoot": "0x140f3e...",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"difficulty": "0xffffffff",
"totalDifficulty": "0x222e4800",
"extraData": "0xd783010703846765746887676f312e392e34856c696e7578",
"size": "0x280",
"gasLimit": "0x47e7c4",
"gasUsed": "0x45f3",
"timestamp": "0x5a5b8d80",
"uncles": [
"0x1602e3..."
]
}
}