Cursor Management
Resume indexing from a specific block using cursors.read() to resume processing from a specific block. The cursor format is { number: blockNumber }. This allows you to restart your indexer without reprocessing all historical data. Store the cursor after successfully processing each batch to enable resumption.
View full example on GitHub
Complete working code with cursor management
Fork Handling
Handle blockchain forks by tracking unfinalized blocks and rolling back when forks occur.fork() handler with blocks from the new consensus chain. The handler finds the common ancestor between your stored blocks and the new chain, then returns the cursor to resume from. Track unfinalized blocks in ctx.state.rollbackChain and prune them as blocks become finalized.
View full example on GitHub
Complete working code with fork handling
ClickHouse Target
Use ClickHouse for automatic cursor management and rollback handling.clickhouseTarget handles cursor management and rollbacks automatically. Use onData to insert new data and onRollback to remove data after a fork point. The target stores cursors in a dedicated table and manages the entire lifecycle of data persistence and fork recovery.
View full example on GitHub
Complete working code with ClickHouse integration

