Crate glin_indexer

Crate glin_indexer 

Source
Expand description

Blockchain indexing utilities for GLIN Network

This crate provides utilities and helpers for building blockchain indexers. It follows the Ethereum SDK pattern (like ethers.js) - providing tools without database, migrations, or server code.

§Features

  • Block Streaming: Subscribe to blocks with a clean, ergonomic API
  • Event Decoding: Decode runtime events to structured data
  • Extrinsic Parsing: Extract signer, call info, and arguments from transactions

§Usage

use glin_client::create_client;
use glin_indexer::{BlockStream, EventDecoder};
use futures::StreamExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Connect to network
    let client = create_client("wss://testnet.glin.ai").await?;

    // Create decoder
    let decoder = EventDecoder::new(&client)?;

    // Subscribe to finalized blocks
    let mut stream = BlockStream::subscribe_finalized(&client).await?;

    while let Some(block) = stream.next().await {
        let block = block?;
        println!("Block #{}: {}", block.number(), block.hash());

        // Decode events
        let events = block.events().await?;
        for event in events.iter() {
            let event = event?;
            let decoded = decoder.decode(&event)?;
            println!("  Event: {}", serde_json::to_string(&decoded)?);
        }
    }

    Ok(())
}

§Architecture Note

This crate provides utilities only. Database models, migrations, and API servers should be implemented in your indexer application (e.g., glin-explorer).

Re-exports§

pub use block_stream::BlockStream;
pub use event_decoder::DecodedEvent;
pub use event_decoder::EventDecoder;
pub use extrinsic_parser::ExtrinsicParser;

Modules§

block_stream
Block streaming utilities
event_decoder
Event decoding utilities
extrinsic_parser
Extrinsic parsing utilities

Structs§

Block
Re-export commonly used types Simplified block representation
Event
Re-export commonly used types Simplified event representation
Extrinsic
Re-export commonly used types Simplified extrinsic representation
ExtrinsicInfo
Re-export commonly used types Detailed extrinsic information