This repository is a starting point of indexing ERC4337 for any chain, entry point and account factory. You can customize the handler logic, chains and addresses as needed.
1️⃣ Clone this repo:
git clone https://github.com/flair-sdk/examples.git examples
cd erc4337-events
2️⃣ Install packages and authenticate:
pnpm i
pnpm flair auth
3️⃣ Set the namespace and config.json:
config.dev.json
and config.prod.json
are sample configs for dev
and prod
clusters.
Set a globally unique namespace in each config file (recommended to use {ORG_NAME}-{ENV}
; e.g sushiswap-dev
or sushiswap-prod
) and then run:
# Setting configs for dev testing
cp config.dev.json config.json
# Or setting it for production
cp config.prod.json config.json
4️⃣ Generate manifest.yml and deploy:
pnpm generate-and-deploy
For the first time it'll take few minutes to create your cluster components.
5️⃣ Backfill certain contracts or block ranges:
# Index last recent 10,000 blocks of a contract like this:
pnpm flair backfill --chain 1 --address 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 -d backward --max-blocks 10000
Or you can backfill for a specific block number, if you have certain events you wanna test with:
pnpm flair backfill --chain 1 -b 17998797 --emit evm-transactions
Or backfill for the recent data in the last X minutes:
pnpm flair backfill --chain 1 --min-timestamp="5 mins ago" -d backward --emit evm-transactions
6️⃣ Look at the logs:
pnpm flair logs --full -tag Level=warn
pnpm flair logs --full -tag TransactionHash=0xXXXXX
pnpm flair logs --full -tag ProcessorId=erc4337-events
pnpm flair logs --full -tag ProcessorId=erc4337-events --watch
7️⃣ Explore the data in playground:
Visit the playground and run the following query in Examples section.
- Method:
POST
- Endpoint: https://api.flair.build/
- Headers:
X-API-KEY: <your-api-key>
- Body:
query {
sql(
query: """
SELECT
*
FROM
entities
WHERE
namespace = 'erc4337-dev'
-- NOTE change the namespace to your own
"""
) {
stats {
elapsedMs
}
rows
}
}
You can sync the indexed data in real-time to your own database. Follow the Database guide.
Q: How do I enable/disable real-time ingestion for indexer?
A: For each indexer defined in config.json
, you can enable/disable it via the enabled: true/false
flag. Remember to run pnpm generate-and-deploy
for the changes to apply on the cluster.