Dart bindings for the Bitcoin Dev Kit (BDK) wallet library.
The repo contains the sources for generating UniFFI-based bindings (lib/bdk.dart) and the
libbdkffi native library, both of which are produced locally (they are gitignored and not
checked into the repository) so Dart and Flutter apps can work with descriptor-based wallets,
key management utilities, and blockchain backends from BDK.
| Path | Purpose |
|---|---|
bdk-ffi/ |
Rust sources and build scripts for the underlying bdk-ffi crate. |
lib/ |
Dart bindings (bdk.dart) generated locally by UniFFI-Dart. |
examples/ |
Standalone Dart examples that exercise common workflows. |
test/ |
Offline/construction/persistence tests (not full integration tests). |
bdk_demo/ |
Flutter sample app you can point at mobile targets once the bindings are built. |
scripts/generate_bindings.sh |
Helper used to rebuild the native library and regenerate the Dart bindings. |
To build the bindings locally you need:
- Dart SDK 3.2 or newer (see
pubspec.yaml). - Rust toolchain with
cargoand the native targets you intend to build. clang/lld(or equivalent platform toolchain) for producing the shared library.- Flutter (optional) if you plan to run
bdk_demo.
Make sure submodules are cloned because the Rust crate lives in bdk-ffi/:
git clone --recurse-submodules https://github.com/bitcoindevkit/bdk-dart.git
cd bdk-dart- Install dependencies:
dart pub get
- Generate the Dart bindings and native binary (requires a macOS or Linux host):
The script builds
./scripts/generate_bindings.sh
bdk-ffi, runs the localuniffi-bindgenwrapper, and drops the resultinglibbdkffi.*alongside the freshly generatedlib/bdk.dart. - Make sure the produced library is discoverable at runtime. For CLI usage you can export
LD_LIBRARY_PATH/DYLD_LIBRARY_PATHor keep the binary in the same directory as your Dart entrypoint.
After generating the bindings you can run the examples or consume the package from your
own project. For instance, the examples/network_example.dart walkthrough shows how to:
- Create a new mnemonic and derive BIP84 descriptors.
- Instantiate a wallet backed by the in-memory persister.
- Reveal addresses and persist staged changes.
- Optionally sync with Electrum over TLS.
Run it with:
dart run examples/network_example.dartWhen embedding in Flutter, add a path or git dependency on this package and ensure the
native library is bundled per target platform (e.g., via flutter_rust_bridge-style
build steps or platform-specific build scripts).
Once you have generated lib/bdk.dart and the native library locally you can execute the
Dart test suite, which covers wallet creation, persistence, offline behavior, and descriptor APIs:
dart testThe Rust crate and generated bindings are dual-licensed under MIT or Apache 2.0 per the
license = "MIT OR Apache-2.0" entry in Cargo.toml. You may choose either license when
using the library in your project.