Skip to content

Commit

Permalink
Merge pull request #106 from chaindexing/update-readme
Browse files Browse the repository at this point in the history
Update README
  • Loading branch information
Jurshsmith authored Apr 19, 2024
2 parents 1a6699b + ff4994e commit 5337e6d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 14 deletions.
81 changes: 70 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,78 @@
[<img alt="crates.io" src="https://img.shields.io/crates/v/chaindexing.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/chaindexing)
[<img alt="diesel-streamer build" src="https://img.shields.io/github/actions/workflow/status/jurshsmith/chaindexing-rs/ci.yml?branch=main&style=for-the-badge" height="20">](https://github.com/jurshsmith/chaindexing-rs/actions?query=branch%3Amain)

An EVM indexing engine that lets you query chain data with SQL.
Index any EVM chain and query in SQL

### Mini Comparison with TheGraph
[Getting Started](#getting-started) | [Examples](https://github.com/chaindexing/chaindexing-examples/tree/main/rust) | [Design Goals & Features](#design-goals--features) | [RoadMap](#roadmap) | [Contributing](#contributing)

It is a great alternative to theGraph [https://thegraph.com/](https://thegraph.com/) if you:
## Getting Started

- have a server + relational database setup
- need to manually create side effects for events
- are NOT indexing hundreds of contracts
- don't want to deal with an additional external system
- want to optimize and save RPC (Alchemy, Infura) cost
- have written your DApp's backend in RUST (Other Languages soon to come!)
📊 Here is what indexing and tracking owers of your favorite NFTs looks like:

### Examples
```rust
use chaindexing::states::{ContractState, Filters, Updates};
use chaindexing::{EventContext, EventHandler, SideEffectContext, SideEffectHandler};

[https://github.com/chaindexing/chaindexing-examples/tree/main/rust](https://github.com/chaindexing/chaindexing-examples/tree/main/rust) contains examples that can be quickly tested and replicated. While the actual documentation is being worked on, feel free to use them as templates and open issues if they don't work correctly.
use crate::states::Nft;

pub struct TransferHandler;

#[async_trait::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](https://github.com/chaindexing/chaindexing-examples/tree/main/rust).

## Design Goals & Features

💸&nbsp;Free forever<br/>
&nbsp;Real-time use-cases<br/>
🌐&nbsp;Multi-chain<br/>
🧂&nbsp;Granular, 🧩 Modular & 📈 Scalable<br/>
🌍&nbsp;Environment-agnostic to allow inspecting 🔍 & replicating indexes anywhere!<br/>
🔓&nbsp;ORM-agnostic, use any ORM to access indexed data<br/>
📤&nbsp;Easy export to your favorite data lake: S3, Snowflake, Redshift<br/>
🚫&nbsp;No complex YAML/JSON/CLI config<br/>
💪&nbsp;Index contracts discovered at runtime<br/>
&nbsp;Handles re-org with no UX impact<br/>
🔥&nbsp;Side effect handling for notifications & bridging use cases<br/>
💸&nbsp;Optimize RPC cost by indexing when certain activities happen in your DApp<br/>
💎&nbsp;Language-agnostic, so no macros!<br/>

## RoadMap

&nbsp;Expose `is_at_block_tail` flag to improve op heuristics for applications<br/>
&nbsp;Support SQLite Database<br/>
&nbsp;Support indexing raw transactions & call traces.<br/>
&nbsp;Improved error handling/messages/reporting (Please feel free to open an issue when an opaque runtime error is encountered)<br/>
&nbsp;SSL Support<br/>
&nbsp;Minimal UI for inspecting events and indexed states<br/>

## Contributing

All contributions are welcome. Before working on a PR, please consider opening an issue detailing the feature/bug. On PR submission, all checks should succeed for a successful review.
2 changes: 1 addition & 1 deletion chaindexing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "chaindexing"
version = "0.1.74"
edition = "2021"
description = "Index any EVM chain and query with SQL"
description = "Index any EVM chain and query in SQL"
license = "MIT OR Apache-2.0"
readme="../README.md"
repository = "https://github.com/chaindexing/chaindexing-rs"
Expand Down
2 changes: 0 additions & 2 deletions chaindexing/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pub async fn start<S: Send + Sync + Clone + Debug + 'static>(config: &Config<S>)
async move {
for chain_ids in get_chunked_chain_ids(&config) {
let config = config.clone();
let node_task = node_task.clone();

let repo_client_for_mcs = repo_client_for_mcs.clone();
let deferred_mutations_for_mcs = deferred_mutations_for_mcs.clone();

Expand Down

0 comments on commit 5337e6d

Please sign in to comment.