chainkit_flutter

chainkit_flutter is a small Flutter package for validating cryptocurrency addresses before you store them, submit withdrawals, or let a user continue through a wallet flow.

It focuses on real address rules instead of simple prefix checks:

  • Bitcoin Base58Check legacy and P2SH addresses
  • Bitcoin native SegWit Bech32 addresses
  • Bitcoin Taproot Bech32m addresses
  • Ethereum EIP-55 checksum addresses
  • BNB Smart Chain 0x addresses
  • Binance Chain BEP2 bnb1 addresses
  • Solana base58-encoded 32-byte public keys

Installation

Add the package to your pubspec.yaml:

dependencies:
  chainkit_flutter: ^0.0.1

Then import it:

import 'package:chainkit_flutter/chainkit_flutter.dart';

Validate a Specific Chain

Use AddressValidator.validate when you already know which chain the user selected.

final isEthereum = AddressValidator.validate(
  address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
  chain: ChainType.ethereum,
);

final isBitcoin = AddressValidator.validate(
  address: '1BoatSLRHtKNngkdXEeobR76b53LETtpyT',
  chain: ChainType.bitcoin,
);

final isSolana = AddressValidator.validate(
  address: '11111111111111111111111111111111',
  chain: ChainType.solana,
);

Detect an Address

Use AddressDetector.detect when you want the package to infer the chain from the address format.

final chain = AddressDetector.detect(
  'bc1qqqqsyqcyq5rqwzqfpg9scrgwpugpzysn4v0345',
);

if (chain == ChainType.bitcoin) {
  // Continue with a Bitcoin flow.
}

For a quick pass/fail check across supported detectable formats, use ChainKit.validateAuto.

final isSupported = ChainKit.validateAuto(
  'bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2',
);

Important Detection Note

Ethereum and BNB Smart Chain both use the same 0x address format. An address alone cannot prove which EVM network the user intended.

For that reason, AddressDetector.detect returns ChainType.ethereum for a valid 0x address. If your UI has a Binance Smart Chain option, validate it explicitly:

final isBscAddress = AddressValidator.validate(
  address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
  chain: ChainType.binance,
);

Supported Formats

Chain Supported formats
Bitcoin Legacy 1..., P2SH 3..., SegWit bc1q..., Taproot bc1p...
Ethereum 0x addresses with EIP-55 checksum support
Solana Base58 addresses that decode to 32 bytes
Binance BNB Smart Chain 0x... and Binance Chain BEP2 bnb1...

Testing

Run the package checks locally before publishing:

flutter analyze
flutter test
dart pub publish --dry-run

License

MIT

Libraries

chainkit_flutter
Address validation utilities for common cryptocurrency chains.