Quickstart: Indexing Arbitrum custom data via Flair
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) to make it easy to receive, transform, store and access your onchain data.
Why Flair?β
Compared to other alternatives the main reasons are:
- π Adopting parallel and distributed processing paradigm means high scalability and resiliency for your indexing stack. Instead of constrained sequential processing (e.g., Subgraph).
 - π§© 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 workload (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.) since we believe to enable 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-20token 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.).
 
Getting Startedβ
1οΈβ£ Clone the starter boilerplate template and follow the instructions
git clone https://github.com/flair-sdk/starter-boilerplate.git
# ... follow instructions in README.md
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.
2οΈβ£ Configure Arbitrum RPC nodes
Set a unique namespace, Arbitrum chainId and RPC endpoint in your config. Remember that you can add up to ten RPC endpoints for resiliency.
{
  'cluster': 'dev',
  'namespace': 'my-awesome-arbitrum-indexing-dev',
  'indexers':
    [
      {
        'chainId': 42161,
        'enabled': true,
        'ingestionFilterGroup': 'default',
        'processingFilterGroup': 'default',
        'sources': [
            # Highly-recommended to have at least 1 websocket endpoint
            'wss://arbitrum-one.publicnode.com',
            # You can put multiple endpoints for failover
            'https://arbitrum.llamarpc.com',
          ],
      },
    ],
}
3οΈβ£ Sync some historical data using backfill command. Remember that enabled: true flag in your config enabled your indexer to capture data in real-time already.
# backfill certain contracts or block ranges
pnpm flair backfill --chain 42161 --address
0x22dc069183f85a8473553e32b59efc9fec506baf -d backward --max-blocks 10000
# backfill for a specific block number, if you have certain events you wanna test with
pnpm flair backfill --chain 42161 -b 132763420
# backfill for the recent data in the last X minute
pnpm flair backfill --chain 42161 --min-timestamp="30 mins ago" -d backward
4οΈβ£ Query your custom indexed data.
5οΈβ£ 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 
USDacross multiple chains - Calculate "Health Factor" of positions with contract factory tracking
 - Index Uniswap v2 swaps with 
USDprice for all addresses 
NFTβ
Need help?β
Our engineers are available to help you at any stage.
