Komodo DeFi SDK (Flutter)

High-level, opinionated SDK for building cross-platform Komodo DeFi wallets and apps. The SDK orchestrates authentication, asset activation, balances, transaction history, withdrawals, message signing, and price data while exposing a typed RPC client for advanced use.

License: MIT style: very good analysis

Features

  • Authentication and wallet lifecycle (HD by default, hardware wallets supported)
  • Asset discovery and activation (with historical/custom token pre-activation)
  • Balances and pubkeys (watch/stream and on-demand)
  • Transaction history (paged + streaming sync)
  • Withdrawals with progress and cancellation
  • Message signing and verification
  • CEX market data integration (Komodo, Binance, CoinGecko) with fallbacks
  • Typed RPC namespaces via client.rpc.*

Install

dart pub add komodo_defi_sdk

Quick start

import 'package:komodo_defi_sdk/komodo_defi_sdk.dart';

final sdk = KomodoDefiSdk(
  host: LocalConfig(https: false, rpcPassword: 'your-secure-password'),
  config: const KomodoDefiSdkConfig(
    defaultAssets: {'KMD', 'BTC', 'ETH'},
  ),
);

await sdk.initialize();

// Register or sign in
await sdk.auth.register(walletName: 'my_wallet', password: 'strong-pass');

// Activate an asset and read a balance
final btc = sdk.assets.findAssetsByConfigId('BTC').first;
await sdk.assets.activateAsset(btc).last;
final balance = await sdk.balances.getBalance(btc.id);

// Direct RPC when needed
final kmd = await sdk.client.rpc.wallet.myBalance(coin: 'KMD');

Configuration

// Host selection: local (default) or remote
final local = LocalConfig(https: false, rpcPassword: '...');
final remote = RemoteConfig(
  ipAddress: 'example.org',
  port: 7783,
  rpcPassword: '...',
  https: true,
);

// SDK behavior
const config = KomodoDefiSdkConfig(
  defaultAssets: {'KMD', 'BTC', 'ETH', 'DOC'},
  preActivateDefaultAssets: true,
  preActivateHistoricalAssets: true,
  preActivateCustomTokenAssets: true,
  marketDataConfig: MarketDataConfig(
    enableKomodoPrice: true,
    enableBinance: true,
    enableCoinGecko: true,
  ),
);

Common tasks

Authentication

await sdk.auth.signIn(walletName: 'my_wallet', password: 'pass');
// Streams for progress/2FA/hardware interactions are also available

Assets

final eth = sdk.assets.findAssetsByConfigId('ETH').first;
await for (final p in sdk.assets.activateAsset(eth)) {
  // p: ActivationProgress
}
final activated = await sdk.assets.getActivatedAssets();

Pubkeys and addresses

final asset = sdk.assets.findAssetsByConfigId('BTC').first;
final pubkeys = await sdk.pubkeys.getPubkeys(asset);
final newAddr = await sdk.pubkeys.createNewPubkey(asset);

Balances

final info = await sdk.balances.getBalance(asset.id);
final sub = sdk.balances.watchBalance(asset.id).listen((b) {
  // update UI
});

Transaction history

final page = await sdk.transactions.getTransactionHistory(asset);
await for (final batch in sdk.transactions.getTransactionsStreamed(asset)) {
  // append to list
}

Withdrawals

final stream = sdk.withdrawals.withdraw(
  WithdrawParameters(
    asset: 'BTC',
    toAddress: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
    amount: Decimal.parse('0.001'),
    // feePriority optional until fee estimation endpoints are available
  ),
);
await for (final progress in stream) {
  // status / tx hash
}

Message signing

final signature = await sdk.messageSigning.signMessage(
  coin: 'BTC',
  message: 'Hello, Komodo!',
  address: 'bc1q...',
);
final ok = await sdk.messageSigning.verifyMessage(
  coin: 'BTC',
  message: 'Hello, Komodo!',
  signature: signature,
  address: 'bc1q...',
);

Market data

final price = await sdk.marketData.fiatPrice(
  asset.id,
  quoteCurrency: Stablecoin.usdt,
);

UI helpers

This package includes lightweight adapters for komodo_ui. For example:

// Displays and live-updates an asset balance using the SDK
AssetBalanceText(asset.id)

Advanced: direct RPC

The underlying ApiClient exposes typed RPC namespaces:

final resp = await sdk.client.rpc.address.validateAddress(
  coin: 'BTC',
  address: 'bc1q...',
);

Lifecycle and disposal

Call await sdk.dispose() when you’re done to free resources and stop background timers.

Platform notes

  • Web uses the WASM build of KDF automatically via the framework plugin.
  • Remote mode connects to an external KDF node you run and manage.
  • From KDF v2.5.0-beta, seed nodes are required unless P2P is disabled. The framework handles validation and defaults; see its README for details.

License

MIT

Libraries

komodo_defi_sdk
A high-level opinionated library that provides a simple way to build cross-platform Komodo Defi Framework applications (primarily focused on wallets). This package consists of multiple sub-packages in the packages folder which are orchestrated by this package (komodo_defi_sdk)