eth_getBlockByHash
curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"id": 1,
"params": [
"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f",
true
]
}
'import requests
url = "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload = {
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"id": 1,
"params": ["0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f", True]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBlockByHash',
id: 1,
params: ['0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f', true]
})
};
fetch('https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_getBlockByHash',
'id' => 1,
'params' => [
'0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f',
true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}Optimism node API
eth_getBlockByHash | Optimism
Optimism API method that retrieves a block’s information by its hash. The block hash is a unique identifier for each block in the blockchain.
POST
/
efb0a5eccd2caa5135eb54eba6f7f300
eth_getBlockByHash
curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"id": 1,
"params": [
"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f",
true
]
}
'import requests
url = "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload = {
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"id": 1,
"params": ["0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f", True]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'eth_getBlockByHash',
id: 1,
params: ['0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f', true]
})
};
fetch('https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'method' => 'eth_getBlockByHash',
'id' => 1,
'params' => [
'0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f',
true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_getBlockByHash\",\n \"id\": 1,\n \"params\": [\n \"0x7e4aea365093a183b0df5f003f26144ef04ec8a6e7f4910356590c5fc7b1671f\",\n true\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": {}
}Optimism API method that retrieves a block’s information by its hash. The block hash is a unique identifier for each block in the blockchain, represented as a hexadecimal number.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
hash— the hash of the block to retrieve, as a hexadecimal string.fullTransactionObjects— a boolean indicating whether to return full transaction objects or only their hashes. Iftrue, full transaction objects are returned; iffalse, only the hashes of the transactions are returned.
Response
result— an object containing the block’s information, including the block number, timestamp, transactions, and more. IffullTransactionObjectsistrue, this will include detailed information about each transaction in the block.
Use case
Theeth_getBlockByHash method is useful for applications that need to retrieve specific blocks from the blockchain, such as block explorers, wallets, or applications that process or display block information. For example, a block explorer might use this method to display detailed information about a block and its transactions to users.Last modified on June 22, 2026
Was this page helpful?