Indexation of the blockchains data

Best Practices for Indexing Chain Data for a Custom Explorer?

Hey everyone,

My friend and I are building our own explorer for a Cosmos-based chain, and we’re debating the best approach to indexing chain data. We’d love your input!

My approach:

I think we should fetch raw transactions from each block, decode them, and then dynamically index the events into our databases using a single script that handles fetching, decoding, and indexing.

My friend’s approach:

He suggests we should index data by querying each module separately (e.g., bank, staking, etc.), then index those results into our databases—essentially having separate scripts or processes for each module.

Our main questions:

  • Which approach is more scalable and maintainable in the long run?

  • What’s considered best practice or industry standard for Cosmos-based explorers?

  • Are there any tools, libraries, or frameworks you’d recommend for either approach?

Would love to hear your experiences, recommendations, or any pitfalls to watch out for!

Thanks in advance :rocket:

2 Likes

We need more data — where and what you want to store, how to retrieve the data, and so on.
But for now, I can say that it’s better to work with separate modules for data retrieval and export.
You can also use versions of AVL trees to update data in the database.

I wanted to store most of the data which is persent on the explorers.

it’s better to work with separate modules for data retrieval and export

Cool project! From what I’ve seen, most explorers lean toward your friend’s approach, indexing per module makes it easier to scale and maintain as the chain evolves. A single script can get messy once you start dealing with upgrades or custom modules. You might want to check out CosmJS and some of the existing indexers like Big Dipper or SubQuery for ideas.

if you need an indexer, let me know. its open source

1 Like