Base
Pronto para usar isso em produção?
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Base
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
Blocks are the unit in which Base records everything — every transfer, swap on Aerodrome or Uniswap, and contract call lands in a block, and the chain appends a new one roughly every 2 seconds through its sequencer. Almost anything you build on Base, from a wallet showing balances to an indexer feeding analytics, ultimately comes down to reading blocks correctly and reacting to new ones, which makes block handling a foundational skill rather than an advanced one. After this guide you will be able to retrieve a block by number or hash over JSON-RPC against https://base.therpc.io/YOUR_API_KEY, watch for new blocks as the sequencer produces them, count confirmations, and reason about when a block on this OP Stack L2 is safe to treat as final.
number and hash, a parentHash linking it to the previous block, a timestamp (Unix seconds), a gasLimit and gasUsed, a baseFeePerGas (Base uses EIP-1559), and the list of transactions. The parentHash chain is what lets you verify continuity and detect reorgs. Its uncles array is always empty on Base, since the single-sequencer model produces no uncle blocks.eth_getBlockByNumber (with a number, or the latest/pending/finalized/safe tags) or eth_getBlockByHash. Passing a true transaction flag returns full transaction objects instead of just hashes, as the getBlock(blockNumber, true) example shows. All of this runs over a single endpoint, https://base.therpc.io/YOUR_API_KEY.newHeads for push delivery at the ~2s cadence, and fall back to polling eth_blockNumber where a subscription is not available.finalized tag) rather than relying on confirmation depth alone.null block result for a head the sequencer has not yet propagated, which should simply wait. Never assume a single call to base.therpc.io succeeds — wrap every block read in explicit error handling.parentHash against the last block you saw and do not treat recent blocks as permanent. Account for reorgs whenever you persist state derived from the latest blocks.baseFeePerGas, gasUsed, and gasLimit across recent blocks so you can price transactions sensibly and detect congestion. On Base these signal when the L2 is busy and fees are climbing, which directly affects whether your transactions land quickly.