TriportRPC

eth_getBlockByNumber

POSThttps://triport.io/rpc/bsc

Return a block by number or tag.

BNB Smart Chainbsc:rpcbsc_read_rpc - 15 / 20 / 100 / 250 RPS (free / basic / pro / business) (default, unmeasured); enterprise unlimited

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

JSON-RPC params is a positional array: [block, fullTransactions].

blockstring (block tag or hex quantity)required
Block selector: latest, earliest, pending, or an EVM hex block number.
fullTransactionsbooleanrequired
When true, return transaction objects; when false, return transaction hashes.

Response

The response below is the checked fixture for this method; it is reproduced without changing its fields or values.

resultobject or null
Block object, or null when the block is unavailable.
result.numberstring or null
Block number as a hex quantity.
result.hashstring or null
Block hash.
result.parentHashstring
Parent block hash.
result.minerstring
Block producer address.
result.gasLimitstring
Block gas limit as a hex quantity.
result.gasUsedstring
Gas used as a hex quantity.
result.timestampstring
Block timestamp as a hex quantity.
result.transactionsarray
Transaction hashes or objects, selected by fullTransactions.
result.unclesarray<string>
Uncle hashes returned by the upstream node.

Errors

Errors use the standard JSON-RPC error envelope. See BSC errors for network-specific classification and the linked shared reference.

CodeMeaningWhen it happens
-32602Invalid paramsA required positional parameter is missing or a value does not match the OpenRPC schema.
-32000Upstream request failureInterpret the message with the code: header not found means a missing block; pruned/unsupported state text means unavailable historical state.
401UnauthorizedThe x-token API key is missing or invalid.
429Rate limitedThe request exceeds the configured category RPS for the caller's tier.

Examples

JavaScript (fetch)

const response = await fetch("https://triport.io/rpc/bsc", {
  method: "POST",
  headers: {
    "x-token": process.env.TRIPORT_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_getBlockByNumber",
    "params": [
      "latest",
      false
    ]
  }),
});


const payload = await response.json();
console.log(payload.result);

Notes