LiteScan - A Lightweight Indexer for Polkadot Chains

LiteScan is an easy to setup, lightweight indexer for Polkadot chains. It uses MongoDB to store data of blocks, extrinsics and events.

If you quickly need to retrieve and store data of Polkadot or one of its parachains, this indexer is for you.

You can find the repository with instructions on how to run with just a few lines of code on Github.

To showcase the indexer, I indexed Polkadot AssetHub and Kusama AssetHub and made the database publicly available at

mongodb://readonly:123456@62.84.182.186:27017/

where you will find two databases:

  • polkadot_asset_hub
  • kusama_asset_hub

each database has 3 collections:

  • blocks
  • extrinsics
  • events

Find an example document below.

For non-technical users who would like to explore that database, I would recommend MongoDB Compass, a visual explorer for MongoDBs where you can connect to the database using the above connection url.

For technical users, a small code snippet here:

import { MongoClient } from "mongodb";

(async () => {
    const dbClient = new MongoClient("mongodb://readonly:123456@62.84.182.186:27017/", {});
    try {
        await dbClient.connect();
        const indexer = dbClient.db("litescan_polkadot_assethub");
        const extrinsics = indexer.collection("extrinsics");
        const query = { method: "transferAllowDeath", section: "balances" };
        const result = await extrinsics.find(query, { limit: 3 });
        const docs = await result.toArray();
        console.dir(docs, { depth: null, colors: true });
    } finally {
        await dbClient.close();
    }
})();

I would be happy to take feedback and feature requests!

Appendix:Example Extrinsic Document:

  {
    _id: '4002698-2',
    isSigned: true,
    method: 'transferAllowDeath',
    assetId: null,
    era: { ImmortalEra: '0x00' },
    metadataHash: null,
    mode: null,
    nonce: '174',
    signature: '0x40916bf848b763229b0f1ca2e8ba48f82132c0751be815b0a3dc4fee6cefead4366286c5176ca81524e7ab7d97103a6bca21beda727cc831fd450479bf24330e',
    signer: { Id: '1JVrK16XZm9vyZjHoYVPjtZ35LvTQ4oyufMoUFTFpAUhath' },
    tip: '0',
    success: true,
    blockNumber: 4002698,
    blockHash: '0xeac3d032a390cefb7ca3bd7ed7d2a34138ae27b0f1f7fb3b9252b8f7e7b6a849',
    timestamp: 1687365288405,
    args: {
      dest: { Id: '153u39aVpaBV7gCrTg4YsJ4UucbrCsUMgDWgVTLwaFdBAhHW' },
      value: '1,020,000,000'
    },
    section: 'balances'
  }
5 Likes

Encointer and Integritee both have good experiences with litescan. Very simple and easy to understand what it does and how it does it. The maintenance burden is very low because it is data-model-agnostic

One nice feature would be a minimalistic frontend block explorer

2 Likes