eth_getBlockByNumber
Retrieves a block by its number or tag from the Ethereum blockchain.
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< TIncludeTransactions extends boolean = false, TBlockTag extends BlockTag = "latest",>( 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>>;
The EIP1193 request function.
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}`; }, ]>;