Block Handlers
Run logic on every block or at an interval!
This is useful for aggregations, time-series logic, and bulk updates using raw SQL. To get started, import the onBlock function from the generated module and call it in one of your handler files.
import { onBlock } from "generated";
onBlock(
{
name: "MyBlockHandler",
chain: 1,
interval: 10,
startBlock: 10_000_000,
},
async ({ block, context }) => {
context.log.info(`Processing block ${block.number}`);
}
);
Read a dedicated documentation page to learn more about the feature and powerful use cases it enables:
- Time intervals
- Preset handler
- Multichain mode
- Different intervals for historical and real-time sync
For inspiration, check out the Example Indexer, which uses all the latest Envio features - Block handlers with different intervals, Effect API, and Traces indexing to get all contracts deployed on Mainnet.
Other changes
- Removed internal
db_write_timestampfield, which was automatically set for every entity.