eth_getBlockByHash

Retrieves a block by its hash.

Example

import { getRpcClient, eth_getBlockByHash } from "thirdweb/rpc";
const rpcRequest = getRpcClient({ client, chain });
const block = await eth_getBlockByHash(rpcRequest, {
blockHash: "0x...",
includeTransactions: true,
});
function eth_getBlockByHash(
request: EIP1193RequestFn<
[
{
Method: "web3_clientVersion";
Parameters?: undefined;
ReturnType: string;
},
{
Method: "web3_sha3";
Parameters: [data: `0x${string}`];
ReturnType: string;
},
{
Method: "net_listening";
Parameters?: undefined;
ReturnType: boolean;
},
{
Method: "net_peerCount";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
{
Method: "net_version";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
]
>,
params: GetBlockByHashParams<TIncludeTransactions>,
): Promise<GetBlockReturnType<undefined, TIncludeTransactions>>;

Parameters

The EIP1193 request function.

Type

let request: EIP1193RequestFn<
[
{
Method: "web3_clientVersion";
Parameters?: undefined;
ReturnType: string;
},
{
Method: "web3_sha3";
Parameters: [data: `0x${string}`];
ReturnType: string;
},
{
Method: "net_listening";
Parameters?: undefined;
ReturnType: boolean;
},
{
Method: "net_peerCount";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
{
Method: "net_version";
Parameters?: undefined;
ReturnType: `0x${string}`;
},
]
>;

The parameters for the block retrieval.

Type

let params: GetBlockByHashParams<TIncludeTransactions>;

Returns

let returnType: Promise<
GetBlockReturnType<undefined, TIncludeTransactions>
>;

A promise that resolves to the retrieved block.