Building a decentralized Bitcoin indexer on ICP

Ordinals (Bitcoin NFTs) have been taking off on Bitcoin. They’ve done hundreds of millions of dollars in volume since their inception in January of this year.

ICP is poised to be the best blockchain to make Bitcoin better with the direct Bitcoin integration and ckBTC implementation. Bitcoin needs speed, scalability, and more capable smart contracts, and ICP can provide it all.

The first initiative that I want to put forward as a community is to build a decentralized Bitcoin indexer on ICP. Here’s what this would look like:

  1. Storage canister: this canister would use the restricted management canister API to pull Bitcoin block data in a decentralized way. This has already been implemented as part of the Bitcoin integration and it would only take an NNS proposal to allow another canister to make calls. Once a block is pulled into the canister, it would parse out all of the locations where people store data on Bitcoin. As far as I know right now, this would be the witness data of the input of a transaction, the op_return in the output, and the multi-sig in the outputs. Including these three data sources would be enough to index Ordinals, Counterparty, and other interesting Bitcoin protocols.
  2. Ordinals indexer canister: this canister would pull the witness data from the storage canister and would then apply the Ordinals protocol to determine Ordinals protocol state. This canister would store the entirety of the Ordinals index (currently 7GB) in stable memory and would be query-able by applications on the Internet Computer or via http_requests.
  3. BRC-20 indexer canister: this canister would pull Ordinals data from the Ordinals indexer canister and follow the BRC-20 protocol to provide BRC-20 state. There is some information that is required here that will need to be provided by the Ordinals indexer canister (original owner of an inscription, transfer history of all inscriptions, etc).
  4. Counterparty indexer canister: this canister would pull all op_return and multi-sig data from the storage canister and would process that data using Counterparty logic. This would enable indexing of Stamps, SRC-20, and other counterparty assets.

Building decentralized Bitcoin indexers on ICP solves many of the current problems with meta-protocol indexers on Bitcoin right now. Some of these problems include:

  1. Centralization. There is no incentive to run a meta-protocol indexer on Bitcoin.
  2. Trusting state. You don’t have any state guarantees or consensus around meta-protocol indexer state. Zero knowledge could help here, but isn’t yet.
  3. Governing protocol changes. There is weak social consensus around protocol changes right now.

By building these on ICP you get a decentralized meta-protocol indexer implementation, you can compare canister hash to code in Github to trust code, and you can govern the implementation using a governance canister. This provides better decentralization, more trust-minimization, and better governance.

This is one of the main initiatives I will be championing over the next 3 months and is a key example of how ICP can make Bitcoin better. If you are interested in getting involved, please reach out. There will be a working group forming around BTC & ICP as well (details coming soon).


I would prefer to see it done in a permissionless way, not relying on the Bitcoin integration. Anyone can feed a block and the canister can verify the proof of work. Feeding blocks can be incentivised in some way. It would be nice to see this approach worked out in detail because then it can be transferred to other chains as well that don’t have any integration in the replica.


Also parsing the Bitcoin transactions itself and indexing them (not the external data) would be huge. Then we can finally have a decentralized Bitcoin block explorer.


Why is the Bitcoin integration not permissionless, assuming this API discussed is eventually opened to all canisters? Wouldn’t this be preferable (at least in key ways) to having others have to submit blocks? The code is open, part of the replica binary, no other infrastructure required, part of IC consensus.


I try to build a decentralized indexer on IC for Name & Service Protocol (GitHub - ldclabs/ns-protocol: NS-Protocol — Inscribing naming trusted database on Bitcoin network), which inscribing naming trusted database on Bitcoin network.
I need some bitcoind API (getblockhash, getblock, waitfornewblock) to get blocks. Is there a canister service like it?