TriportRPC

eth_getBlockByNumber

BNB Smart Chain / https://triport.io/rpc/bsc

Minimum tier: Free

BNB Smart Chain method guide

Last updated:

eth_getBlockByNumber returns a BNB Smart Chain block selected by tag or hex block number, or null when it is unavailable.

Set fullTransactions to false for transaction hashes or true for transaction objects. The block fields and all numeric quantities use the EVM JSON-RPC encoding defined by the OpenRPC schema.

Use this method when block metadata or transaction membership is required. For only the transaction count, eth_getBlockTransactionCountByNumber is smaller; for all receipts, use eth_getBlockReceipts.

Parameters

eth_getBlockByNumber parameters
NameTypeRequiredDescription
blockBlockTagYes
fullTransactionsBooleanYes

Returns

eth_getBlockByNumber return value
FieldType
blockBlockOrNull

Examples

curl https://triport.io/rpc/bsc \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["<block>","<fullTransactions>"]}'
const res = await fetch("https://triport.io/rpc/bsc", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getBlockByNumber",
  "params": [
    "<block>",
    "<fullTransactions>"
  ]
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/rpc/bsc",
    headers={"Authorization": "Bearer <api-key>"},
    json={"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["<block>","<fullTransactions>"]},
)
print(resp.json())

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Chain: BNB Smart Chain.
  3. Clusters: mainnet.
  4. Credit cost: 1 per call.

FAQ

What does eth_getBlockByNumber do?
Return a block by number or tag.
How many credits does eth_getBlockByNumber cost?
eth_getBlockByNumber costs 1 credit(s) per call on Triport by default.
Is eth_getBlockByNumber available over WebSocket?
eth_getBlockByNumber is an HTTP JSON-RPC method.