Expand description
§Mycelium TFChain Client
A Rust client for interacting with TFChain using dynamic metadata. This means no compile-time codegen is required - the client discovers the chain’s metadata at runtime.
§Features
- Dynamic metadata: No need to regenerate code when the chain upgrades
- Key management: Create keypairs from BIP-39 mnemonics or secret URIs
- Storage queries: Query twins, farms, nodes, contracts, and balances
- Transactions: Transfer TFT tokens between accounts
- Explorer API: High-level client for Grid Proxy with optional Redis caching
§Quick Start
use mycelium_tfchain_client::{Client, KeyPair, KeyType};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create keypair from mnemonic
let mnemonic = "your twelve word mnemonic phrase here ok";
let keypair = KeyPair::from_phrase(KeyType::Sr25519, mnemonic, None)?;
let account_id = keypair.account_id();
// Connect to TFChain mainnet
let client = Client::new("wss://tfchain.grid.tf:443").await?;
// Query balance
if let Some(info) = client.get_balance(&account_id).await? {
let tft = info.free as f64 / 10_000_000.0;
println!("Balance: {} TFT", tft);
}
Ok(())
}§Network Endpoints
| Network | WebSocket URL |
|---|---|
| Mainnet | wss://tfchain.grid.tf:443 |
| Testnet | wss://tfchain.test.grid.tf:443 |
| Devnet | wss://tfchain.dev.grid.tf:443 |
Modules§
- explorer
- ThreeFold Grid Explorer API client.
Structs§
- Account
Info - Account balance information.
- Client
- The TFChain client with dynamic metadata support.
- Farm
- Farm data structure representing a collection of nodes.
- KeyPair
- A cryptographic keypair for signing transactions.
- Node
- Node data structure representing a compute node on ThreeFold Grid.
- Public
Ip - Public IP address owned by a farm.
- Resources
- Hardware resources available on a node.
- Twin
- Twin data structure representing a TFChain identity.
Enums§
- KeyType
- Supported cryptographic key types.
- TfChain
Error - Error types for the TFChain client.