Documentation
Architecture of the Indexer SDK
Section titled “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:
- Receive a stream of transactions from Transaction Stream
- Extract the relevant data from the transactions and transform it into a standardized schema
- Store the transformed data into a database
- 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.
When to use the Indexer SDK
Section titled “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:
- Define your database schema
- Create a new processor
- Create
Step
s that extract and transform data into your storage schema - Customize your processor by adding and connecting steps
- Run your processor and see the data indexed into your database
Benefits of the Indexer SDK
Section titled “Benefits of the Indexer SDK”The Indexer SDK’s architecture simplifies writing custom processors in several ways:
- You can reuse
Step
implementations across processors which reduces duplication of common data extraction logic. - The SDK collects basic performance metrics, like the number of transactions processed, for each
Step
, which enables observability into subcomponents of the processor. - Since each
Step
is independent, you can safely customize parts of the processor without breaking the other pieces. For example, you can add additionalStep
’s to pre/post-process data or batch data writes. EachStep
can also be tested in isolation from the rest of the processor.