Skip to content

Index any EVM chain and query in SQL

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

chaindexing/chaindexing-rs

Folders and files

NameName
Last commit message
Last commit date
Apr 21, 2024
Apr 20, 2024
May 9, 2024
Sep 15, 2023
Aug 25, 2023
Sep 17, 2023
Feb 8, 2024
Feb 8, 2024
Apr 20, 2024
Apr 21, 2024
Sep 27, 2024
May 4, 2024
Sep 24, 2023

Repository files navigation

Chaindexing

github crates.io diesel-streamer build

Index any EVM chain and query in SQL

Getting Started | Examples | Design Goals & Features | RoadMap | Contributing

Getting Started

πŸ“Š Here is what indexing and tracking owers of your favorite NFTs looks like:

use chaindexing::states::{ContractState, Filters, Updates};
use chaindexing::{EventContext, EventHandler};

use crate::states::Nft;

pub struct TransferHandler;

#[chaindexing::augmenting_std::async_trait]
impl EventHandler for TransferHandler {
    fn abi(&self) -> &'static str {
        "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
    }
    async fn handle_event<'a, 'b>(&self, context: EventContext<'a, 'b>) {
        let event_params = context.get_event_params();

        let _from = event_params.get_address_string("from");
        let to = event_params.get_address_string("to");
        let token_id = event_params.get_u32("tokenId");

        if let Some(existing_nft) =
            Nft::read_one(&Filters::new("token_id", token_id), &context).await
        {
          let updates = Updates::new("owner_address", &to);
          existing_nft.update(&updates, &context).await;
        } else {
            let new_nft = Nft {
                token_id,
                owner_address: to,
            };

            new_nft.create(&context).await;
        }
    }
}

A quick and effective way to get started is by exploring the comprehensive examples provided here: https://github.com/chaindexing/chaindexing-examples/tree/main/rust.

Design Goals & Features

  • πŸ’Έ Free forever
  • ⚑ Real-time use-cases
  • 🌐 Multi-chain
  • πŸ§‚ Granular, 🧩 Modular & πŸ“ˆ Scalable
  • 🌍 Environment-agnostic to allow inspecting πŸ” & replicating indexes anywhere!
  • πŸ”“ ORM-agnostic, use any ORM to access indexed data
  • πŸ“€ Easy export to any data lake: S3, Snowflake, etc.
  • 🚫 No complex YAML/JSON/CLI config
  • πŸ’ͺ Index contracts discovered at runtime
  • ✨ Handles re-org with no UX impact
  • πŸ”₯ Side effect handling for notifications & bridging use cases
  • πŸ’Έ Optimize RPC cost by indexing when certain activities happen in your DApp
  • πŸ’Ž Language-agnostic, so no macros!

RoadMap

  • ⬜ Expose is_at_block_tail flag to improve op heuristics for applications
  • ⬜ Support SQLite Database (Currently supports only Postgres)
  • ⬜ Support indexing raw transactions & call traces.
  • ⬜ Improved error handling/messages/reporting (Please feel free to open an issue when an opaque runtime error is encountered)
  • ⬜ Support TLS connections
  • ⬜ Minimal UI for inspecting events and indexed states

Contributing

All contributions are welcome. Before working on a PR, please consider opening an issue detailing the feature/bug. Equally, when submitting a PR, please ensure that all checks pass to facilitate a smooth review process.