avalanche_flutter_sdk 0.1.1-dev
avalanche_flutter_sdk: ^0.1.1-dev copied to clipboard
The first native Flutter/Dart SDK for the Avalanche network. Pure Dart, no platform channels. Covers C-Chain EVM, Data API (Glacier), P-Chain staking, and X-Chain native assets.
Changelog #
All notable changes to avalanche_flutter_sdk will be documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.1.1-dev #
Phase 2 started: C-Chain JSON-RPC client and EIP-1559 gas estimation implemented and verified against official Avalanche documentation.
Added #
CChainClient: JSON-RPC client for the Avalanche C-ChaingetBalance(address): AVAX balance in Wei (eth_getBalance)getTransactionCount(address): nonce (eth_getTransactionCount)getBlockNumber(): latest accepted block (eth_blockNumber)getTransactionReceipt(txHash): receipt or nullgetBaseFee(): next block base fee in Wei (eth_baseFee, Avalanche-specific)getMaxPriorityFeePerGas(): tip in Wei (eth_maxPriorityFeePerGas)suggestPriceOptions(): slow/normal/fast gas options (eth_suggestPriceOptions, Avalanche-specific)estimateGas({to, from, value, data}): gas units (eth_estimateGas)- Throws
AvalancheExceptionon RPC and HTTP errors
GasEstimator: higher-level EIP-1559 gas estimationgetPriceOptions(): delegates toeth_suggestPriceOptionsgetBaseFee(): delegates toeth_baseFeegetOption(GasSpeed): returns single tier (slow/normal/fast)estimateTransferFee(speed): maxFeePerGas × 21,000 gas unitsavaxTransferGasLimit: 21,000 (standard EVM transfer cost)
GasPriceOption: EIP-1559 fee model for a single speed tiermaxPriorityFeePerGasandmaxFeePerGasin WeieffectiveFee(baseFee):min(maxFeePerGas, baseFee + maxPriorityFeePerGas)maxPriorityFeePerGasInNAvaxandmaxFeePerGasInNAvaxhelpers
GasPriceOptions: container for slow, normal, and fast tiersGasSpeedenum:slow,normal,fast- 24 new unit tests (254/254 -> 278/278 total passing)
Verified #
eth_suggestPriceOptionsresponse format verified against official example frombuild.avax.network/docs/rpcs/c-chain#eth_suggestpriceoptions- EIP-1559 effective fee formula verified:
min(gasFeeCap, baseFee + gasTipCap)perbuild.avax.network/docs/rpcs/other/guides/txn-fees - Avalanche burns both base fee AND priority fee (unlike Ethereum where priority fee goes to validators)
- Minimum base fee: 1 nAVAX (1 Gwei = 10^9 Wei)
Status #
Phase 2 in progress: C-Chain read operations available.
Not ready for production use.
Next: AvaxTransferTransaction (EIP-1559 signing and broadcast)
-> v0.1.2-dev
0.1.0-dev #
Phase 1 complete: full wallet cycle implemented and verified. Given a mnemonic, the SDK can now derive addresses for all three Avalanche chains (C-Chain, X-Chain, P-Chain).
Added #
Seed: BIP-39 seed derivation via PBKDF2-HMAC-SHA512Seed.fromMnemonic(): derives 512-bit seed from aMnemonicinstance with optional passphraseSeed.fromPhrase(): derives from raw phrase string- Password and salt normalized to UTF-8 NFKD per BIP-39 spec
toString()returnsSeed[REDACTED]
HDWallet: BIP-32/BIP-44 hierarchical deterministic walletHDWallet.fromSeed(): derives master key viaHMAC-SHA512(key="Bitcoin seed", data=seed)HDWallet.fromMnemonic(): convenience constructorderivePrivateKeyForCChain(index): pathm/44'/60'/0'/0/n(coin_type=60, EVM-compatible, Core Wallet + MetaMask)derivePrivateKeyForXPChain(index): pathm/44'/9000'/0'/0/n(coin_type=9000, Avalanche native)derivePublicKeyForCChain(index)andderivePublicKeyForXPChain(index)convenience methodstoString()returnsHDWallet[REDACTED]
EvmAddress: C-Chain EVM address derivationEvmAddress.fromPublicKey(): keccak256(toRawUncompressed()) → last 20 byteschecksumAddress: EIP-55 mixed-case checksum with0xprefixlowercaseAddress: lowercase hex with0xprefixEvmAddress.fromHex(): import from hex string
XPAddress: X-Chain and P-Chain Bech32 address derivationXPAddress.fromPublicKey(): SHA256(compressed) → RIPEMD160 → 20 bytes → Bech32xChainAddress(network):X-avax1{bech32}(mainnet) orX-fuji1{bech32}(testnet)pChainAddress(network):P-avax1{bech32}(mainnet) orP-fuji1{bech32}(testnet)AvalancheNetworkenum:mainnet(hrp=avax),fuji(hrp=fuji)
- 46 new unit tests (208/208 → 254/254 total passing)
Verified #
- PBKDF2 seed derivation verified against 3 official Trezor
test vectors (trezor/python-mnemonic/vectors.json, passphrase="TREZOR"):
abandon x11 + about→c55257...3b04legal winner...yellow→2e8905...f607letter advice...above→d71de8...52a8
- BIP-44 derivation paths verified from Core Wallet official docs:
support.core.app/en/articles/7004986 - EIP-55 checksum verified against 4 official test vectors
(
eips.ethereum.org/EIPS/eip-55):0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d3590xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb
- X/P-Chain address algorithm verified from official Avalanche spec:
docs.avax.network/docs/rpcs/other/standards/cryptographic-primitives
Status #
Phase 1 complete: full wallet cycle operational.
Not ready for production use.
Next: Phase 2 -> C-Chain JSON-RPC client (EIP-1559 transfers, ERC-20).
0.0.3-dev #
Phase 1 in progress: BIP-39 mnemonic generation implemented and verified in English and Spanish.
Added #
MnemonicStrength: enum with 5 valid BIP-39 entropy strengthswords12(128 bits),words15(160 bits),words18(192 bits),words21(224 bits),words24(256 bits)- Computes
bits,bytes,checksumBits,totalBits,wordCountper BIP-39 formula: CS = ENT / 32, MS = (ENT + CS) / 11
Entropy: BIP-39 entropy generation and checksum computationgenerate(): cryptographically secure random bytes usingFortunaRandom+Random.secure()(consistent withPrivateKey)validate(): throwsArgumentErrorfor invalid entropy sizescomputeChecksum(): first ENT/32 bits of SHA256(entropy)toBits(): entropy + checksum as bit list for word index computation
Wordlist: abstract base class for BIP-39 wordlistswordAt(index): returns word at index 0-2047indexOf(word): binary search O(log n) - valid per BIP-39 sorted speccontains(word): delegates toindexOfvalidate(): checks length == 2048 and words are sorted
WordlistEn: official BIP-39 English wordlist (2048 words)- Singleton pattern:
WordlistEn.instance - Source:
github.com/bitcoin/bips/blob/master/bip-0039/english.txt - First word:
abandon(index 0), last word:zoo(index 2047)
- Singleton pattern:
WordlistEs: official BIP-39 Spanish wordlist (2048 words)- Singleton pattern:
WordlistEs.instance - Source:
github.com/bitcoin/bips/blob/master/bip-0039/spanish.txt - NFKD encoding (per BIP-39 spec);
wordAt()returns NFC for callers - Accent-insensitive lookup:
indexOf('abaco') == indexOf('ábaco') - HashMap-based O(1) lookup (binary search invalid for Spanish alphabet where ñ follows n, not unicode order)
- Case-insensitive:
indexOf('Domingo') == indexOf('domingo')
- Singleton pattern:
Mnemonic: BIP-39 mnemonic generation, import, and validationMnemonic.generate(): generates from cryptographically secure entropy; default 12 words English, configurable strength and wordlistMnemonic.fromEntropy(): deterministic generation from entropy bytesMnemonic.fromPhrase(): imports and validates existing phrase; verifies BIP-39 checksum; accepts extra whitespace between wordstoEntropy(): reconstructs original entropy from word indicestoString()returnsMnemonic[REDACTED]- phrase is equivalent in sensitivity to a private key; usephrasegetter explicitly
- SDK Documentation & Knowledge Base link added to README
- 192 new unit tests (77/77 → 192/192 total passing)
Verified #
- BIP-39 official test vectors (trezor/python-mnemonic/vectors.json):
- 128-bit all-zeros →
abandon abandon ... about(12 words) ✅ - 128-bit 0x7f...7f →
legal winner ... yellow(12 words) ✅ - 128-bit 0x80...80 →
letter advice ... above(12 words) ✅ - 128-bit 0xff...ff →
zoo zoo ... wrong(12 words) ✅ - 256-bit all-zeros →
abandon abandon ... art(24 words) ✅
- 128-bit all-zeros →
- Spanish wordlist: 2048 words in NFKD encoding, accent-insensitive lookup verified at runtime
WordlistEnbinary search:wordAt/indexOfround-trip consistent at indices 0, 1024, and 2047
Status #
Phase 1 in progress: BIP-39 mnemonics (EN + ES) complete and tested.
Not ready for production use.
Next: HD key derivation (BIP-44) + EVM and X/P-Chain address derivation.
0.0.2-dev #
Phase 1 in progress: secp256k1 cryptography implemented and verified.
Added #
PrivateKey: secp256k1 private key generation, import, and exportPrivateKey.generate()usingFortunaRandom(cryptographically secure pseudo-random number generator)PrivateKey.fromHex()with strict range validation against the curve ordern(rejectsd <= 0andd >= n)toHex(),toBytes(): 32-byte big-endian exportpublicKeygetter: derivesQ = d * Gper secp256k1toString()returnsPrivateKey[REDACTED]- key material is never exposed via logs, error messages, or debug output
PublicKey: secp256k1 public key derivation, import, and encodingPublicKey.fromEcPoint(),PublicKey.fromHex()(accepts both compressed and uncompressed SEC1 encodings)toCompressed(): 33-byte SEC1 encoding - required input for X-Chain/P-Chain address derivation (sha256 + ripemd160)toUncompressed()/toRawUncompressed(): 65-byte and 64-byte encodings - required input for C-Chain/EVM address derivation (keccak256)- Value equality (
==,hashCode) based on the underlying elliptic curve point
pointycastle: ^4.0.0andmeta: ^1.15.0added as dependencies- 60 new unit tests (18/18 -> 78/78 total passing)
Verified #
- secp256k1 curve order
nconfirmed directly frompointycastle'sECDomainParameters('secp256k1')at runtime:fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 - Private key range validation tested at all boundaries:
d=0(rejected),d=1(accepted),d=n-1(accepted),d=n(rejected),d=n+1(rejected) - Compressed/uncompressed public key encodings verified to decode to the same elliptic curve point (round-trip equality)
Status #
Phase 1 in progress: secp256k1 PrivateKey/PublicKey complete and
tested.
Not ready for production use.
Next: CB58 encoding, then EVM and X/P-Chain address derivation.
0.0.1-dev #
Phase 1 in progress: SDK skeleton and project architecture.
Added #
AvalancheClient: main entry point for the SDK- accepts
NetworkConfigfor Mainnet or Fuji Testnet
- accepts
NetworkConfig: official Avalanche RPC endpoint configurationsNetworkConfig.mainnet: Avalanche Mainnet (C-Chain, P-Chain, X-Chain, Glacier API)NetworkConfig.fuji: Avalanche Fuji Testnet (C-Chain, P-Chain, X-Chain, Glacier API)- endpoint URLs sourced from
docs.avax.network
NetworkId: enum for Mainnet (1) and Fuji Testnet (5)AvalancheException: base exception class for all SDK errorsanalysis_options.yamlwithvery_good_analysislinter (zero warnings enforced)scripts/pre_commit.ps1: local quality gate (format + analyze + test).github/workflows/ci.yml: GitHub Actions CI pipeline- format check, static analysis, test suite, coverage threshold (85%), pub publish dry-run
- daily integration test job against Fuji Testnet (on
developpush)
.github/pull_request_template.md: PR checklistCONTRIBUTING.md: branch strategy, commit conventions, code and testing standardsSECURITY.md: vulnerability reporting policy and key handling rules- 6 initial unit tests (6/6 passing)
Status #
Phase 1 in progress: SDK skeleton, project architecture, and CI infrastructure complete.
Not ready for production use.
Next: secp256k1 key generation, BIP-39 mnemonics (EN + ES), HD key derivation (BIP-44).