Polygon
Polygon
Polygon
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Blocks are the unit of truth on Polygon: every balance, event, and transaction receipt is recorded in a Bor block, and a new one arrives on chain 137 roughly every 2 seconds. Whether you are tracking deposits, indexing events, or confirming a MATIC transfer, reading and reasoning about blocks correctly is the foundation everything else stands on. After this guide you will be able to retrieve blocks by number or hash from https://polygon.therpc.io/YOUR_API_KEY, monitor the chain head in real time, count confirmations, and understand what finality actually means on Polygon — the groundwork for the more advanced reorg, gas, and best-practice guides that follow.
number, hash, parentHash linking it to the previous block, the validator-set timestamp (~2s apart), gasLimit and gasUsed, and baseFeePerGas from the EIP-1559 fee market. The body holds the list of transactions. The parentHash chain is what lets you verify continuity and detect reorgs.eth_getBlockByNumber and eth_getBlockByHash (wrapped here as web3.eth.getBlock). Pass a number, a hash, or a tag such as latest; pass true as the second argument to expand full transaction objects instead of just hashes, as the blockWithTx example shows.newBlockHeaders for low latency rather than polling, and always process by block number so you neither skip nor double-handle a Bor block.latest rather than chasing a stale block number.getBlock returns null (the block is not yet available or you queried beyond the head), distinguish a network timeout from a malformed response, and never let an unhandled error silently drop a Bor block from your processing — that gap is how state drifts from PolygonScan.parentHash against the one you recorded, and wait past the shallow-reorg window — or for a Heimdall checkpoint — before treating a block as final.baseFeePerGas and how full recent blocks are (gasUsed versus gasLimit) so you price transactions to confirm promptly without overpaying in MATIC. A run of near-full blocks signals congestion on chain 137 and a rising base fee.