eth_getBlockByNumber

Retrieves a block by its number or tag from the Ethereum blockchain.

Example

import { getRpcClient, eth_getBlockByNumber } from "thirdweb/rpc";
const rpcRequest = getRpcClient({ client, chain });
const block = await eth_getBlockByNumber(rpcRequest, {
blockNumber: 123456,
includeTransactions: true,
});
function eth_getBlockByNumber(
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: GetBlockParameters<TIncludeTransactions, TBlockTag>,
): Promise<
GetBlockReturnType<undefined, TIncludeTransactions, TBlockTag>
>;

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 retrieving the block.

Type

let params: GetBlockParameters<TIncludeTransactions, TBlockTag>;

Returns

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

A promise that resolves to the requested block.