Polygon
Prêt à utiliser cela en production ?
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
Polygon
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
A script that reads Polygon blocks on your laptop can ignore failed requests, shallow Bor reorgs, and memory growth — a production service cannot. At ~2 seconds per block, chain 137 produces tens of thousands of blocks a day, and any gap, duplicate, or unhandled error compounds into state that no longer matches PolygonScan. Production-grade block handling demands explicit retry logic, reorg awareness, bounded memory, and observability that development code never needs. This guide delivers the concrete patterns and copy-ready checklists to run Polygon block processing reliably against https://polygon.therpc.io/YOUR_API_KEY, from robust fetching through reorg recovery to the monitoring you ship before going live.
eth_getBlock calls 3–5 times with exponential backoff and jitter (1s, 2s, 4s). Keep the window short relative to Polygon's ~2s block time — if a recent height keeps failing, re-anchor to latest rather than hammering a stale block number.parentHash against the hash you last recorded. On a mismatch, walk back to the common ancestor, roll back any state derived from the orphaned blocks, and re-apply the canonical chain — never mutate irreversible state on a block that is still within reorg range.https://polygon.therpc.io/YOUR_API_KEY, and skip work when latest has not advanced. A newBlockHeaders subscription is cheaper still and reacts within the block window.processBlockRange example does. Never load an unbounded number of Bor blocks into memory at once — stream the range so peak memory stays flat regardless of how many blocks you cover.parentHash form a continuous chain with the block you handled previously. Reject any block whose parent does not match your recorded head — that gap is the signature of a reorg or a node serving inconsistent data.baseFeePerGas, a misread parentHash, or a number/BigInt mix-up before it ships. Typed shapes are the cheapest defense against silently mishandling chain 137 data.parentHash mismatch routes into reorg recovery rather than throwing into the void.latest, that block timestamps advance roughly every 2 seconds, and that the breaker and fallback are armed. Surface the result on a status dashboard.https://polygon.therpc.io/YOUR_API_KEY degrades, fail over to the secondary automatically and keep tracking the last processed block so the failover node resumes exactly where the primary left off, with no skipped or duplicated Bor blocks.parentHash continuity.