avalanche_flutter_sdk
The first native Flutter/Dart SDK for the Avalanche network.
Pure Dart · No platform channels · Apache 2.0 · pub.dev
⚠️ Status: Early Development - API is not stable.
Phase 1 complete: full wallet cycle (mnemonic > seed > HD wallet > addresses). Current: Phase 2 C-Chain Core.
Planned Features (v1.0.0)
| Feature | Status |
|---|---|
| AvalancheClient + NetworkConfig (Mainnet / Fuji) | ✅ Done |
| secp256k1 PrivateKey / PublicKey | ✅ Done |
| CB58 encoding / decoding | ✅ Done |
| BIP-39 mnemonics (EN + ES) | ✅ Done |
| HD key derivation (BIP-44) | ✅ Done |
| EVM address derivation (C-Chain) | ✅ Done |
| X/P-Chain address derivation | ✅ Done |
| C-Chain JSON-RPC client (eth_getBalance, eth_getTransactionCount) | ✅ Done |
| AVAX transfers (EIP-1559, signing, broadcast) | 🔄 M2 |
| ERC-20 transfers (USDC, USDT, approve, allowance) | ⏳ M2 |
| Glacier REST client (balances, transaction history) | ⏳ M3 |
| Glacier WebSocket (real-time events, subscriptions) | ⏳ M3 |
| ERC-721 / ERC-1155 (NFT metadata, ownership) | ⏳ M3 |
| P-Chain staking (addValidator, addDelegator) | ⏳ M4 |
| P-Chain validator queries | ⏳ M4 |
| X-Chain UTXO transfers (native AVAX) | ⏳ M4 |
| Cross-chain (Export/Import C↔X↔P) | ⏳ M4 |
SDK Documentation & Knowledge Base
This SDK is built on top of the Avalanche Knowledge Base, an in-depth guide to the Avalanche network covering consensus, architecture, multi-chain design, and the development ecosystem. Recommended reading before diving into the SDK internals.
Every implementation decision behind this SDK - library choices, encoding standards, verification against official specs - is documented in docs-sdk/.
Installation
# pubspec.yaml
dependencies:
avalanche_flutter_sdk: ^0.1.1-dev
flutter pub get
Quick Start
Network Configuration
import 'package:avalanche_flutter_sdk/avalanche_flutter_sdk.dart';
// Fuji Testnet
final client = AvalancheClient(network: NetworkConfig.fuji);
print(client.network.cChainRpcUrl);
// -> https://api.avax-test.network/ext/bc/C/rpc
// Mainnet
final client = AvalancheClient(network: NetworkConfig.mainnet);
print(client.network.networkId); // -> 1
Key Generation (secp256k1)
// Generate a new private key
final privateKey = PrivateKey.generate();
// Derive the public key
final publicKey = privateKey.publicKey;
// Export / import via hex
final hex = privateKey.toHex(); // 64 hex chars (32 bytes)
final imported = PrivateKey.fromHex(hex); // round-trips correctly
// Private keys are always redacted in logs
print(privateKey); // PrivateKey[REDACTED]
print(publicKey); // PublicKey(0x02b33c...)
Public Key Encodings
final publicKey = PrivateKey.generate().publicKey;
// Compressed (33 bytes) - input for X/P-Chain address derivation
final compressed = publicKey.toCompressed();
// Raw uncompressed (64 bytes, no 0x04 prefix) - input for C-Chain EVM
final raw = publicKey.toRawUncompressed();
CB58 Encoding / Decoding
// Encode raw bytes to CB58 (PrivateKey export, NodeID, etc.)
final bytes = Uint8List.fromList([1, 2, 3, 4, 5]);
final encoded = CB58.encode(bytes); // e.g. "3HCXF4n..."
final decoded = CB58.decode(encoded); // back to original bytes
// PrivateKey in Avalanche export format: "PrivateKey-<cb58>"
final privateKey = PrivateKey.generate();
final exportString = 'PrivateKey-${CB58.encode(privateKey.toBytes())}';
BIP-39 Mnemonics (English + Spanish)
// Generate a 12-word English mnemonic (default)
final mnemonic = Mnemonic.generate();
print(mnemonic.phrase);
// -> "abandon ability able about above absent absorb..."
// Generate a 24-word Spanish mnemonic
final mnemonicEs = Mnemonic.generate(
strength: MnemonicStrength.words24,
wordlist: WordlistEs.instance,
);
print(mnemonicEs.phrase);
// -> "ábaco abdomen abeja abierto abogado..."
// Import from existing phrase (validates checksum automatically)
final imported = Mnemonic.fromPhrase(
'abandon abandon abandon abandon abandon abandon '
'abandon abandon abandon abandon abandon about',
);
// Mnemonics are always redacted in logs
print(mnemonic); // Mnemonic[REDACTED]
print(mnemonic.phrase); // the actual phrase
HD Wallet + Address Derivation
// Generate wallet from mnemonic (English or Spanish)
final mnemonic = Mnemonic.generate(wordlist: WordlistEs.instance);
final wallet = HDWallet.fromMnemonic(mnemonic);
// C-Chain address (EVM) - compatible with Core Wallet + MetaMask
// Path: m/44'/60'/0'/0/n
final cPubKey = wallet.derivePublicKeyForCChain(index: 0);
final cAddress = EvmAddress.fromPublicKey(cPubKey);
print(cAddress.checksumAddress); // 0x71C7656EC7ab88b098defB751B7401B5...
print(cAddress.lowercaseAddress);
// X-Chain address - Avalanche native
// Path: m/44'/9000'/0'/0/n
final xpPubKey = wallet.derivePublicKeyForXPChain(index: 0);
final xpAddress = XPAddress.fromPublicKey(xpPubKey);
print(xpAddress.xChainAddress()); // X-avax1...
print(xpAddress.xChainAddress(network: AvalancheNetwork.fuji)); // X-fuji1...
// P-Chain address (same key as X-Chain, different prefix)
print(xpAddress.pChainAddress()); // P-avax1...
// Wallets and seeds are always redacted in logs
print(wallet); // HDWallet[REDACTED]
C-Chain - Read Operations
import 'package:avalanche_flutter_sdk/avalanche_flutter_sdk.dart';
// Connect to Fuji Testnet
final client = CChainClient(network: NetworkConfig.fuji);
// Read AVAX balance (returns Wei - divide by 10^18 for AVAX)
final balance = await client.getBalance('0x71C7656EC7...');
print(balance); // e.g. 1000000000000000000 (= 1 AVAX)
// Read nonce (required for signing transactions)
final nonce = await client.getTransactionCount('0x71C7656EC7...');
// Get gas price options (Avalanche-specific)
final estimator = GasEstimator(client);
final options = await estimator.getPriceOptions();
print(options.normal.maxFeePerGas); // in Wei
print(options.fast.maxFeePerGas); // in Wei
// Estimate fee for a simple AVAX transfer
final fee = await estimator.estimateTransferFee();
print(fee); // maxFeePerGas * 21000 gas units
Networks
| Network | Chain ID | C-Chain RPC |
|---|---|---|
| Mainnet | 1 | https://api.avax.network/ext/bc/C/rpc |
| Fuji Testnet | 5 | https://api.avax-test.network/ext/bc/C/rpc |
Contributing
The SDK is not ready for external contributions yet. Follow this repository for updates; contributions will be welcome starting with v1.0.0.
See CONTRIBUTING.md for future guidelines.
License
Licensed under Apache 2.0.
Para desarrolladores en LATAM
Este SDK esta siendo desarrollado con soporte nativo para la region:
- Mnemonics BIP-39 en español ✅ disponible desde v0.0.3-dev
- HD wallet + direcciones en las 3 chains ✅ disponible desde v0.1.0-dev
- Caso de uso principal: remesas Estados Unidos hacia Latinoamerica
- Desarrollado por Nemorix Group, Ohio, USA
Siguenos para actualizaciones: sdks@nemorixpay.com
Support This Project
If this SDK is useful to you or your team, consider supporting its development. Every contribution helps cover infrastructure, documentation, and the time invested in building and maintaining this open source tool for the Avalanche and Flutter community. Thank you!
Built by Nemorix Group · Apache 2.0
Libraries
- avalanche_flutter_sdk
- The first native Flutter/Dart SDK for the Avalanche network.