eth_getBlockByNumber - Arc RPC Method
Retrieve complete block data by block number on Arc. Perfect for payment platforms, stablecoin issuers, exchange and treasury teams, and Solidity developers building on Arc building on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality.
Returns information about a block by block number on Arc.
Why Arc? Build on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality with USDC as the native gas token, sub-second irreversible finality, an EWMA-smoothed fee market with a 20 Gwei floor, and EIP-7708 Transfer logs for native value movement.
When to Use This Method
eth_getBlockByNumber is essential for payment platforms, stablecoin issuers, exchange and treasury teams, and Solidity developers building on Arc:
- Block explorers and analytics dashboards: Display comprehensive block data and chain metrics for end-user interfaces on Arc
- Transaction indexers processing block contents: Extract and index every transaction within a block for data pipelines and search backends
- Cross-chain bridges verifying block data: Validate block headers and transaction proofs for crossborder settlement, merchant payments, institutional clearing, and USDC-denominated financial applications
- Timestamp-based logic: Verify block age and enforce time-dependent contract logic on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality
Common Use Cases
1. Process All Transactions in the Latest Block
Fetch the latest block on Arc with full transaction objects, then iterate through each transaction to extract sender, receiver, value, and gas data. This pattern powers indexers, analytics dashboards, and event backfill pipelines.
import { JsonRpcProvider, formatEther } from 'ethers';
const provider = new JsonRpcProvider('https://api-arc-mainnet.n.dwellir.com/YOUR_API_KEY');
async function processLatestBlock() {
const block = await provider.getBlock('latest', true);
if (!block) return;
console.log(`Block #${block.number}: ${block.transactions.length} transactions`);
for (const tx of block.prefetchedTransactions) {
console.log(` ${tx.hash}`);
console.log(` From: ${tx.from} To: ${tx.to}`);
console.log(` Value: ${formatEther(tx.value)} Gas: ${tx.gasLimit.toString()}`);
}
}
processLatestBlock();2. Monitor New Blocks with a Polling Loop
Poll eth_getBlockByNumber at regular intervals to detect new blocks as they are produced on Arc. This lightweight pattern is suitable for bots, watchers, and notification services that need near-real-time block awareness.
from web3 import Web3
import time
w3 = Web3(Web3.HTTPProvider('https://api-arc-mainnet.n.dwellir.com/YOUR_API_KEY'))
last_block = w3.eth.block_number
print(f'Starting from block #{last_block}')
while True:
current_block = w3.eth.block_number
if current_block > last_block:
for block_num in range(last_block + 1, current_block + 1):
block = w3.eth.get_block(block_num)
tx_count = len(block.transactions)
print(f'New block #{block.number}: {tx_count} txns, '
f'gas used {block.gasUsed}')
last_block = current_block
time.sleep(2)3. Verify Block Finality on L2 Chains
Layer 2 rollup chains on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality expose additional block tags that indicate settlement confidence. Use safe or finalized tags alongside the base latest tag for use cases requiring strong finality guarantees.
package main
import (
"context"
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
client, _ := ethclient.Dial("https://api-arc-mainnet.n.dwellir.com/YOUR_API_KEY")
// Latest block (may be unconfirmed on L2)
latest, _ := client.BlockByNumber(context.Background(), nil)
fmt.Printf("Latest block: %d (timestamp: %d)\n",
latest.Number().Uint64(), latest.Time())
// Finalized block (settled on L1 for rollups)
finalized, _ := client.BlockByNumber(context.Background(),
big.NewInt(int64(RPCLatestBlockNumber-32))) // placeholder: use rpc.FinalizedBlockNumber
if finalized != nil {
fmt.Printf("Finalized block: %d\n", finalized.Number().Uint64())
}
}Best Practices
- Cache block data by block number: Blocks are immutable once finalized, so cache results indefinitely keyed by block number to eliminate redundant API calls
- Use
latesttag for most use cases; avoidpendingfor production: Thependingtag returns speculative data that may never be included in the canonical chain - For L2 chains, check chain-specific finality tags: Tags like
safeandfinalizedprovide settlement guarantees specific to each rollup's proof mechanism - Combine with
eth_getBlockReceiptsfor efficient receipt scanning: When you need both block headers and transaction outcomes, useeth_getBlockReceiptsalongside this method rather than fetching receipts individually
Arc block header notes
Four header fields behave differently on Arc than on Ethereum:
extraDatacarries the next block's base fee, as an 8-byte big-endian value. Read it to price a transaction for the block you are about to land in.timestampis non-decreasing, not strictly increasing. Timestamps come from the proposer's wall clock at one-second granularity, and Arc produces sub-second blocks, so consecutive blocks can share a timestamp. Order events by block number, never by timestamp.mixHash/PREVRANDAOis always0. Arc has no beacon-chain RANDAO, so there is no onchain randomness source. The EIP-4788 beacon-roots contract is also omitted;parentBeaconBlockRootis set to the parent execution block hash and reads from the beacon-roots contract return empty.withdrawalsis always empty. Arc has no EIP-4895 withdrawals.
Blocks are final on commit. Arc's Malachite BFT consensus gives deterministic finality in under a second, so a block returned by this method will never be reorganized out.
Code Examples
Error Handling
| Error Code | Message | Description |
|---|---|---|
| -32602 | Invalid params | Invalid block number or parameter format |
| -32000 | Block not found | Block does not exist |
Related Methods
eth_blockNumber- Get latest block numbereth_getBlockByHash- Get block by hasheth_getTransactionByHash- Get transaction details
eth_blockNumber
Get the current block height on Arc. Essential for syncing dApps, monitoring transaction confirmations, and blockchain state tracking.
eth_getBlockByHash
Retrieve complete block data by block hash on Arc. Essential for payment platforms, stablecoin issuers, exchange and treasury teams, and Solidity developers building on Arc building on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality.