Bitcoin Rare Sats now live Get started

Article: How SimpleHash handles chain re-orgs

Published on: 5/15/2023

How SimpleHash handles chain re-orgs

What is a re-org?

A blockchain “re-org”, short for "blockchain reorganization," is an event that can occur in a blockchain network when two or more miners find and broadcast valid blocks at roughly the same time. Since there is no definitive "first" block, some nodes in the network might initially see one block as the most recent while other nodes see another.

When this happens, there can be a temporary fork in the blockchain, where different nodes see different versions of the blockchain. This can cause confusion as nodes may not be in agreement about the correct state of the network.

To resolve this situation, the network must agree on which version of the blockchain to keep as the true version. This agreement is typically achieved through a consensus mechanism such as proof of work, or proof of stake, where the network collectively decides which blocks to keep based on which chain is the longest or has the most work done on it, or some other mechanism.

If a re-org results in a significant change to the blockchain, such as a rollback of previously confirmed transactions, it can have significant implications for the network's security and can be exploited by bad actors. Therefore, it is essential to handle re-orgs properly and quickly to maintain the integrity and security of the blockchain network.

For NFT data, re-orgs are problematic as they may result in conflicting information on who holds a particular token, or where / how it was transferred, causing problems for end user applications.

How SimpleHash handles these situations

SimpleHash gracefully handles chain re-orgs across the networks we support, meaning that developers don’t need to worry about handling these situations in their apps.

As new blocks are ingested by the SimpleHash indexer, it constantly checks if each block has a parent block that has not yet been seen within the system. If the indexer identifies such a parent block, it indicates a re-org event. In response, the indexer re-indexes the relevant blocks, by deleting the blocks determined not to be part of the chain, and inserting the ones that are deemed to be correct according to the chain consensus mechanism.

For the REST API, the changes to the provenance data, which refers to who holds which tokens, are reflected in near-real-time once the re-indexing process is completed, usually taking less than a few seconds. This means that REST API users will see the updated transaction data shortly after the re-org event has occurred.

For developers who are subscribed to transfer events for a specific chain, wallet, NFT or collection, webhooks are fired to indicate any changes to transactions after the re-org event. This ensures that developers receive real-time updates on the updated transactions, allowing them to keep their systems up-to-date with the most current blockchain state.

Using SimpleHash, developers can have confidence that chain re-orgs will be reflected quickly and reliably, allowing them to focus on their end-user applications, not the intricacies of different blockchain finality mechanisms.

About SimpleHash

SimpleHash is the world’s leading provider of NFT data, and a leader in implementation of new NFT standards. Developers using the API can get instant access to metadata, media, transaction history, sales, floor prices, listings, rarity scores and collection info across 20 chains. To get started, read through our API docs, or reach out at hello@simplehash.com

Getting NFT data is hard.

SimpleHash makes it easy.

Trusted by hundreds of web3 leaders:

Coinbase logo
Floor logo
Ledger logo
Brave logo
Rarible logo
Rainbow logo
Phantom logo
Manifold logo
Venly logo
Bitwave logo
Zerion logo
Nansen logo
Dappradar logo
Dust Labs logo
Bitski logo
Mask logo
Crossmint logo
Tiplink logo