Skip to content
🎉 Welcome to the new Aptos Docs! Click here to submit feedback!

Documentation

Architecture of the Indexer SDK

In the Aptos indexing stack, a processor indexes a specific subset of data from the blockchain and writes the data into an external database.

Each processor follows this general flow:

  1. Receive a stream of transactions from Transaction Stream
  2. Extract the relevant data from the transactions and transform it into a standardized schema
  3. Store the transformed data into a database
  4. Keep track of the transaction versions that have been processed

The Indexer SDK allows you to write a processor as a directed graph of independent steps. Each Step has an input and output, and the output of each Step is connected to the input of the next Step by a Kanal channel.

Indexer SDK Custom Processor Architecture

When to use the Indexer SDK

The Indexer SDK is useful when you want to index a custom contract or you realize you need a new kind of data that isn’t available in the Indexer API.

The general flow to write a custom processor with the Indexer SDK is:

  1. Define your database schema
  2. Create a new processor
  3. Create Steps that extract and transform data into your storage schema
  4. Customize your processor by adding and connecting steps
  5. Run your processor and see the data indexed into your database

Benefits of the Indexer SDK

The Indexer SDK’s architecture simplifies writing custom processors in several ways:

  1. You can reuse Step implementations across processors which reduces duplication of common data extraction logic.
  2. The SDK collects basic performance metrics, like the number of transactions processed, for each Step, which enables observability into subcomponents of the processor.
  3. Since each Step is independent, you can safely customize parts of the processor without breaking the other pieces. For example, you can add additional Step’s to pre/post-process data or batch data writes. Each Step can also be tested in isolation from the rest of the processor.