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.
- π Network connection and RPC
- π Account management and signing
- π Contract deployment and interaction
- πΈ Transaction building and submission
- π‘ Event subscriptions
- π Metadata parsing
- π¨ CLI tools with colored output and progress bars
- β‘ High-performance blockchain indexing
- β Contract verification utilities
- π§ Type-safe contract code generation
This is a Cargo workspace containing four crates:
- glin-client: Network connection, accounts, and RPC operations
- glin-contracts: Contract metadata, deployment, interaction, and verification
- glin-types: Shared types and data structures
- glin-indexer: Blockchain indexing utilities (block streaming, event decoding)
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-forge: CLI tools for ink! contract development
- glinscan (planned): Blockchain explorer and indexer
- Your project here! π
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:
- glin-sdk: TypeScript/JavaScript SDK (frontend + backend)
- glin-sdk-rust (this repo): Rust SDK (backend + CLI tools)
- glin-sdk-python (planned): Python SDK (data science + analytics)
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 warningsContributions are welcome! Please read CONTRIBUTING.md for details.
Apache-2.0 - see LICENSE for details
- Website: https://glin.ai
- Documentation: https://docs.glin.ai
- GitHub: https://github.com/glin-ai
- Discord: https://discord.gg/glin-ai
- Twitter: https://twitter.com/glin_ai
- General: hello@glin.ai
- Technical: dev@glin.ai
- Security: security@glin.ai