Flair
Real-time and historical custom data indexing for any evm chain.
Flair offers reusable indexing primitives (such as fault-tolerant RPC ingestors, custom processors, re-org aware database integrations) for receiving, transforming, storing, and accessing your on-chain data.
Why Flair?
- 🚀 A parallel and distributed processing paradigm, rather than constrained sequential processing, supports your indexing stack's scalability and resiliency.
- 🧩 Focused on primitives, which means on the left you plug in an RPC and on the right you output the data to any destination database.
- 🚄 Native real-time stream processing for certain data workloads (such as aggregations, rollups) for things like total volume per pool, or total portfolio per user wallet.
- ☁️ Managed cloud services avoid DevOps and irrelevant engineering costs for dapp developers.
- 🧑💻 Avoid decentralization overhead (consensus, network hops, etc.). We believe the best UX for dapps reading data must be as close to the developers as possible.
Features
- ✅ Listen to any EVM chain with just an RPC URL.
- Free managed RPC URLs for 8+ popular chains already included.
- Works with both websocket and https-only RPCs.
- ✅ Track and ingest any contract for any event topic.
- Auto-track new contracts deployed from factory contracts.
- ✅ Custom processor scripts with Javascript runtime (with Typescript
support)
- Make external API or Webhook calls to third-party or your backend.
- Get current or historical USD value of any ERC-20 token amount of any contract address on any chain.
- Use any external NPM library.
- ✅ Stream any stored data to your destination database (Postgres, MongoDB, MySQL, Kafka, Elasticsearch, Timescale, etc).
Get started
- Clone the starter boilerplate template and follow the instructions:
git clone https://github.com/flair-sdk/starter-boilerplate.git
# ... follow instructions in README.md
info
Boilerplate instructions will create a new cluster, generate an API Key,
and set up a manifest.yml
to index your first contract with sample
custom processor scripts.
Learn more about the structure of manifest.yml
.
- Configure Linea RPC nodes. Set a unique namespace, Linea
chainId
and RPC endpoint in yourconfig
. Remember that you can add up to 10 RPC endpoints for resiliency.
{
"cluster": "dev",
"namespace": "my-awesome-linea-indexing-dev",
"indexers":
[
{
"chainId": 59140,
"enabled": true,
"ingestionFilterGroup": "default",
"processingFilterGroup": "default",
"sources": [
# Having at least 1 websocket endpoint is highly recommended
"wss://linea-mainnet.infura.io/v3/xxxxxxxxxx",
"https://linea-mainnet.infura.io/v3/xxxxxxxxxx",
# You can add multiple endpoints for failover
"https://rpc.linea.build",
],
},
],
}
- Sync some historical data using the
backfill
command. Remember that theenabled: true
flag in yourconfig
already enables your indexer to capture data in real-time.
# backfill certain contracts or block ranges
pnpm flair backfill --chain 59140 --address 0x0872ec4426103482a50f26ffc32acefcec61b3c9 -d backward --max-blocks 10000
# backfill for a specific block number, if you have certain events you wanna test with
pnpm flair backfill --chain 59140 -b 409652
# backfill for the recent data in the last X minute
pnpm flair backfill --chain 59140 --min-timestamp="30 mins ago" -d backward
-
Query your custom indexed data.
-
Stream the data to your own database.
Examples
Explore real-world usage of Flair indexing primitives for various use cases.
DeFi
- Aggregate protocol fees in USD across multiple chains
- Calculate "Health Factor" of positions with contract factory tracking
- Index Uniswap v2 swaps with USD price for all addresses
NFT
Need help?
Our engineers are available to help you at any stage.