Skip to content

berestovskyy/blockchain-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain Indexer

An experimental blockchain indexer focused on the Infura API. It supports multiple chains and tokens, features RPC and query caching, and is built using the alloy and tokio crates.

Example Usage

An Infura API key is required to run the indexer. A free key can be obtained from Infura.

Example backend output:

% RUST_LOG=info INFURA_API_KEY=<YOUR KEY> cargo run --release
    Finished `release` profile [optimized] target(s) in 0.20s
2026-04-28T10:30:31.995827Z  INFO backend: Opening caching DB ./cache/db...
2026-04-28T10:30:31.997335Z  INFO backend::index: Starting indexing timestamp range 1763337600..1763339600... chain=Eth
2026-04-28T10:30:31.997372Z  INFO backend::index: Starting indexing timestamp range 1763337600..1763339600... chain=Bsc
2026-04-28T10:30:31.997392Z  INFO backend::index: Converting timestamp range 1763337600..1763339600 to block range... chain=Eth
2026-04-28T10:30:31.997423Z  INFO backend::index: Converting timestamp range 1763337600..1763339600 to block range... chain=Bsc
2026-04-28T10:30:31.997663Z  INFO backend: Listening on localhost:8081...
2026-04-28T10:30:36.485151Z  INFO backend::index: Indexing block range 68448664..68451331 (2667 blocks)... chain=Bsc
2026-04-28T10:31:05.370814Z  INFO backend::index: Indexing block range 23815180..23815346 (166 blocks)... chain=Eth
[...]
2026-04-28T10:31:12.970902Z  INFO backend::index: [100%]: 4 tasks done out of 4 chain=Eth
2026-04-28T10:31:12.972934Z  INFO backend::index: Ready to serve timestamp range 1763337600..1763339600 in 7s chain=Eth
[...]
2026-04-28T10:32:47.379897Z  INFO backend::index: [95%]: 41 tasks done out of 43 chain=Bsc
2026-04-28T10:32:48.625433Z  INFO backend::index: Ready to serve timestamp range 1763337600..1763339600 in 132s chain=Bsc

Once the backend is ready to serve requests on Ethereum and BNB Smart Chain (BSC), open a new terminal window and run the query:

% curl "localhost:8081/api/volume?chain=eth&token=USDT&aggregation=30min&from=1763337600&to=1763339600" | jq
{
  "chain": "eth",
  "token": "USDT",
  "aggregation": "30min",
  "from_bucket": 1763337600,
  "to_bucket": 1763341200,
  "buckets": [
    {
      "bucket_ts": 1763337600,
      "bucket_volume": 2216412555.10703
    },
    {
      "bucket_ts": 1763339400,
      "bucket_volume": 399550376.343273
    }
  ]
}

See the config module for additional configuration options.

Database Keys Serialization Benchmark

This project includes a performance comparison of various key serialization methods.

See benches/DB-KEYS.md for more details.

About

An experimental blockchain indexer focused on the Infura API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors