Ethereum
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Ethereum
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
In development you fetch a block, log it, and move on. Production is a different animal. You're processing every one of the ~7,200 blocks Ethereum produces per day without gaps, surviving node hiccups, and staying correct when the head reorgs out from under you. The cost of a missed block or a double-counted reorg isn't a console warning — it's drifted balances and support tickets. That's why the rigor here goes well past the happy-path code you'd write for a quick script.
The patterns below are the ones that hold up against sustained mainnet traffic: retrying failed reads without losing data, detecting reorgs by watching parentHash, processing wide block ranges without exhausting memory, and failing over to a second provider when the primary degrades. Each comes with a checklist you can lift straight into a readiness review before you point real users at https://ethereum.therpc.io/YOUR_API_KEY.
eth_getBlock in a retry loop of 3 to 5 attempts with delays that double from a fraction of a second. Since a fresh block arrives every 12 seconds, treat a block that's still missing after a few seconds as genuinely absent rather than retrying indefinitely against an empty result.parentHash to the hash you stored for the previous height. If they differ, the chain reorganized: walk back to the common ancestor, undo any state derived from the orphaned blocks, then replay the new canonical ones. Never mutate finalized-block-derived state — only the unfinalized tail can move.eth_chainId of 0x1 and agrees on the hash at a recent shared height before you trust its data, so failover doesn't quietly hand you a forked or lagging view.finalized are immutable — store them keyed by hash with no expiry. The unfinalized tail between finalized and latest can still change, so cap that cache to a short window (a couple of slots) sized to your reorg tolerance, not to RAM convenience.eth_getBlockByNumber calls. The win is mostly in connection and request overhead, which dominates on Ethereum's dense ranges where each block carries hundreds of transactions.finalized tag, reached after roughly two epochs (~12.8 minutes), beyond which a revert would require slashing a third of staked ETH. Low-value or reversible actions can act on safe or a handful of blocks; settlement-grade flows should wait for finalized.parentHash chains to the prior stored block, and that its number is exactly one above it. A gap or a mismatch means either a reorg or a node fault — handle it before you derive any state.number, timestamp, gasLimit, baseFeePerGas all come back as 0x-prefixed quantities. TypeScript types around your parsing layer catch the classic bug of comparing a hex string as if it were a decimal number, and document which fields exist post-Merge (an empty uncles array, sha3Uncles as the empty-list hash) versus pre-Merge.parentHash doesn't match, a batch where one read fails, and the resume-from-cursor restart. Happy-path block fetching rarely breaks; the reorg and recovery code is where regressions hide.latest-to-finalized gap drifting past its normal ~2-epoch span, RPC error rate, reorg depth, and processing throughput against the ~12-second block cadence. These tell you the pipeline is falling behind or the chain is misbehaving.eth_chainId returns 0x1, and that your cursor is advancing. A node can answer requests while quietly stuck — only a freshness check catches that.latest and never check parentHash, a routine head reorg leaves you having acted on a block that no longer exists on the canonical chain. On Ethereum these short reorgs are normal before finality, so this isn't an edge case — it's a matter of when.