| Crates.io | glin-indexer |
| lib.rs | glin-indexer |
| version | 0.1.4 |
| created_at | 2025-10-10 14:51:08.151966+00 |
| updated_at | 2025-10-10 14:51:08.151966+00 |
| description | Blockchain indexing utilities for GLIN Network - helpers for block streaming, event decoding, and extrinsic parsing |
| homepage | https://docs.glin.ai/sdk/rust/setup |
| repository | https://github.com/glin-ai/glin-sdk-rust |
| max_upload_size | |
| id | 1877043 |
| size | 118,325 |
Official Rust SDK for GLIN Network - A decentralized AI training platform built on Substrate.
Complete Rust SDK for building applications on GLIN Network. Provides all core blockchain features (same as TypeScript and Python SDKs) plus Rust-specific extensions for high-performance tools.
This is a Cargo workspace containing four crates:
Add to your Cargo.toml:
[dependencies]
glin-client = "0.1.0"
glin-contracts = "0.1.0"
# Or use local path during development
glin-client = { path = "../glin-sdk-rust/glin-client" }
glin-contracts = { path = "../glin-sdk-rust/glin-contracts" }
use glin_client::{create_client, GlinClient};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Connect to network
let client = create_client("wss://testnet.glin.ai").await?;
// Use client for RPC calls
let block_hash = client.rpc().finalized_head().await?;
println!("Latest finalized block: {:?}", block_hash);
Ok(())
}
use glin_client::{get_dev_account, account_from_seed, get_address};
// Development accounts
let alice = get_dev_account("alice")?;
println!("Alice address: {}", get_address(&alice));
// From seed phrase
let keypair = account_from_seed("//Alice")?;
// From mnemonic
let mnemonic = "word1 word2 word3 ... word12";
let keypair = account_from_seed(mnemonic)?;
use glin_contracts::{fetch_contract_metadata, MetadataFetchOptions};
let options = MetadataFetchOptions {
local_path: None,
explorer_url: Some("https://glinscan.com".to_string()),
cache_dir: Some("/home/user/.glin/cache".to_string()),
};
let metadata = fetch_contract_metadata(
&client,
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
options
).await?;
use glin_contracts::get_contract_info;
let info = get_contract_info(&client, contract_address).await?;
println!("Code hash: 0x{}", hex::encode(info.code_hash));
println!("Storage deposit: {}", info.storage_deposit);
Build DApps and services on GLIN Network:
use glin_client::GlinClient;
use glin_contracts::Contract;
// Connect and interact with contracts
let client = create_client("wss://testnet.glin.ai").await?;
let contract = Contract::new(&client, address, metadata)?;
Build developer tools like glin-forge:
use colored::Colorize;
use glin_client::create_client;
println!("{} Deploying contract...", "→".cyan());
let client = create_client(rpc_url).await?;
println!("{} Connected!", "✓".green().bold());
Build high-performance blockchain indexers like glinscan:
use glin_client::create_client;
use glin_indexer::{BlockStream, EventDecoder, ExtrinsicParser};
use futures::StreamExt;
let client = create_client("wss://testnet.glin.ai").await?;
let decoder = EventDecoder::new(&client)?;
let parser = ExtrinsicParser::new();
let mut stream = BlockStream::subscribe_finalized(&client).await?;
while let Some(block) = stream.next().await {
let block = block?;
// Parse extrinsics
for ext in block.extrinsics().await?.iter() {
let info = parser.parse(&ext?, block.number())?;
// Store in database...
}
// Decode events
for event in block.events().await?.iter() {
let decoded = decoder.decode(&event?)?;
// Store in database...
}
}
See examples/block_indexer.rs for a complete example.
glin-sdk-rust/
├── glin-client/ # Network & RPC
│ ├── Connection management
│ ├── Account utilities
│ ├── Block subscriptions
│ └── Batch operations
│
├── glin-contracts/ # Contract utilities
│ ├── Metadata fetching
│ ├── Chain info queries
│ ├── Encoding/decoding
│ ├── Metadata parsing
│ └── Contract verification
│
├── glin-types/ # Shared types
│ ├── Block types
│ ├── Event types
│ ├── Extrinsic types
│ ├── Account types
│ └── Contract types
│
└── glin-indexer/ # Indexing utilities (NEW in v0.2.0)
├── BlockStream - Block subscription helper
├── EventDecoder - Event decoding utilities
└── ExtrinsicParser - Transaction parsing
GLIN Network provides SDKs for multiple languages:
All SDKs share the same core features, with language-specific extensions. See Rust SDK Documentation → for details.
# Clone repository
git clone https://github.com/glin-ai/glin-sdk-rust.git
cd glin-sdk-rust
# Build all crates
cargo build
# Run tests
cargo test
# Check formatting
cargo fmt --check
# Lint
cargo clippy --all-targets --all-features -- -D warnings
Contributions are welcome! Please read CONTRIBUTING.md for details.
Apache-2.0 - see LICENSE for details