bark: Ark on bitcoin

bark_bitcoin

Dart bindings for Bark


Bark is an implementation of the Ark protocol on bitcoin, led by Second. The Ark protocol is a bitcoin layer 2 for making fast, low-cost, self-custodial payments at scale. Ark uses a client-server model to enable users to transact off-chain while still being able to "exit" their balances on-chain at any time.

Works in Dart and Flutter apps.

Installation

Requirements

  • Dart 3.10+ (Flutter 3.38+)
  • rustup: the native library is compiled from source by a Dart build hook, and the pinned Rust toolchain installs itself on the first build
  • protoc, the Protocol Buffers compiler (brew install protobuf, apt install protobuf-compiler, …)
  • The C toolchain for your target: Xcode for iOS and macOS, the Android NDK for Android, MSVC for Windows

pub.dev

dart pub add bark_bitcoin    # or: flutter pub add bark_bitcoin

Or add it to pubspec.yaml:

dependencies:
  bark_bitcoin: ^0.27.0+bark-0.8.1

The first build compiles the whole Rust dependency tree and takes a few minutes. Later builds are cached.

Quick start

import 'package:bark_bitcoin/bark_bitcoin.dart';

Future<void> main() async {
  // Store the mnemonic securely: you need it to reopen the wallet.
  final mnemonic = generateMnemonic();

  final config = Config(
    serverAddress: 'https://ark.signet.2nd.dev',
    esploraAddress: 'https://esplora.signet.2nd.dev',
  );

  // Opens the wallet in datadir, creating it on first launch.
  // In Flutter, use a directory from path_provider instead.
  final wallet = await Wallet.open(
    network: Network.signet,
    mnemonicOrSeed: mnemonic,
    config: config,
    args: WalletOpenArgs(datadir: './bark-data'),
  );

  await wallet.sync_();

  final balance = await wallet.balance();
  print('Spendable: ${balance.spendableSats} sats');

  final address = await wallet.newAddress();
  print('Ark address: $address');

  wallet.dispose();
}

Failures are thrown as ErrorException.

Example app

bark-flutter-example is a Flutter wallet built on this package that sends and receives over Ark and Lightning, on signet or mainnet.

Platform support

Platform Architectures
Android arm64-v8a, armeabi-v7a, x86_64, x86
iOS arm64
iOS Simulator arm64, x86_64
macOS arm64, x86_64
Linux x86_64, arm64
Windows x86_64, arm64

Web is not supported: the bindings use dart:ffi.

Resources

Support

License

Released under the MIT license.

Libraries

bark_bitcoin