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.
Code that works against Base in development often fails in production because the conditions change: at ~2s per block the sequencer emits roughly 43,000 blocks a day, transient RPC errors that never appeared in testing become routine at scale, shallow reorgs rewrite the head, and a naive loop over a large block range will exhaust memory long before it finishes. Production-grade block management has to assume all of that. This guide collects the patterns and checklists we recommend for running Base block processing against https://base.therpc.io/YOUR_API_KEY under real load — robust retries and recovery, reorg-safe state handling, memory-efficient batch processing, and the operational monitoring that keeps a pipeline healthy on an OP Stack rollup settling to Ethereum L1.
eth_getBlockByNumber in a bounded retry with exponential backoff and jitter (1s, 2s, 4s, max 3–5 tries), as shown in the fetchBlockWithRetry helper below. Distinguish a transient error (timeout, 5xx, rate limit) which should retry, from a null result for a not-yet-propagated head block, which should simply wait for the next ~2s Base block instead of retrying the same height.parentHash equals the hash of your last processed block. If it does not, walk back to the common ancestor, roll back the side effects of the orphaned blocks, and reprocess the canonical chain — never apply a block whose parent you have not seen.processBlockRange helper below fetches in batches of 10; batching a wide range cuts round trips and Compute Unit spend against base.therpc.io dramatically compared with one request per block.newHeads subscription and reserve polling for backfill.Promise.all over thousands of blocks at once. Process in fixed-size windows, hand each batch to your processor, and release it before fetching the next so heap usage stays flat regardless of range size — essential given how many blocks Base produces per hour.parentHash chains to your last block, and its hash is internally consistent. Reject anything that breaks the chain rather than trusting whatever a node returns.parentHash mismatches, timestamps that move backward, a block number gap or jump, or the sequencer going silent far longer than the normal ~2s interval as a malfunction or attack signal — pause irreversible actions and alert until the head behaves normally again.baseFeePerGas exists (Base is EIP-1559) and that hex quantities are parsed as bigint, not silently truncated to JavaScript numbers.null block results, and malformed responses explicitly, with the retry/backoff and reorg checks described above rather than a bare try/catch that swallows the error.base.therpc.io URL never reaches a log line.null head, a timeout that triggers retry, a parentHash mismatch that triggers rollback, and a large-range batch. Mock the Base RPC so these run deterministically in CI.eth_blockNumber is advancing, that lag is within bounds, that chain ID is still 8453, and that the fallback endpoint is reachable before you need it.https://base.therpc.io/YOUR_API_KEY degrades, automatically promote the secondary, keep serving cached immutable historical blocks, and queue work that must hit the head until a healthy endpoint is available rather than dropping it.null checks will silently skip blocks the moment base.therpc.io returns a transient error, leaving permanent gaps in your processed data that are painful to find and backfill later.null heads, or reorgs is fragile by construction — it passes in development and breaks the first time Base behaves the way production always eventually does.