# Indexer

See [BlocksTxIndexer](https://github.com/0xweb-org/dequanto/blob/master/src/indexer/BlocksTxIndexer.ts)🔗 for details.

With the indexer, you can go through a range of blocks and handle the transactions.

A range can be specified by block numbers or dates. The Indexer can also listen for incoming block headers and transactions.

```typescript
import { BlocksTxIndexer } from '@dequanto/indexer/BlocksTxIndexer'

let indexer = new BlocksTxIndexer(platform, {
    name: 'foo worker',
    // loads also transactions from the mined blocks
    loadTransactions: true,
    // saves blockNumbers of already processed blocks
    persistance: true,
});

indexer.onBlock(async (
    client: Web3Client, 
    block: BlockTransactionString, 
    txs: Transaction[]
) => {
    // process txs
});

// starts indexing from the block at specified date
// as no end date is provided, after indexer is ready, it will listen for incomming blocks
indexer.start(new Date('2022-04-22T00:00:00Z'));

// gets current status 
let status = indexer.stats();

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.0xweb.org/dequanto/indexer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
