Kasplex Indexer

Here you can learn about how the Kasplex indexer works and even build your own.

Introduction to Indexer

The Indexer operates by continuously monitoring the blockchain for new blocks and transactions. For each token transaction, the Indexer updates the corresponding token balances for the involved addresses, maintaining a detailed record of token ownership and distribution. It also stores metadata associated with each token, including its name, symbol, total supply, and any custom properties defined by token deployer.

ScriptPubKey Extraction and Type Checking

  • The Indexer scans all transactions in each block, extracting the scriptPubKey.

  • It checks its type, specifically looking for Pay-to-Script-Hash (P2SH).

  • If the script type is P2SH, the UTXO is cached into the database. This caching ensures that future references to this UTXO do not require re-parsing the blockchain.(and to avoid being unable to query due to pruning)

Signature Script Extraction and KRC-20 Check

  • The Indexer then extracts the signature script from the first input (Inputs[0]) of the transaction.

  • It checks for any KRC-20 related opcodes within the signature script.

  • Upon detecting a KRC-20 opcode, the Indexer computes the transaction gas fee using the cached UTXO data.

Parsing and Storing KRC-20 Data

  • The Indexer parses the KRC-20 relevant data from the transaction and stores this information into the database.

  • This information includes various state changes triggered by the specific KRC-20 opcodes detected in the transaction.

Last updated