Skip to content

DartSV

DartSV is a Bitcoin SV library for Dart. It runs wherever Dart runs, which means Flutter apps on mobile, desktop and the web, command-line tools, and servers. Everything it does is local. It creates keys, builds and signs Transactions, and checks them with its own Script Interpreter. It does not talk to the network. To broadcast a Transaction one hands it to a broadcaster such as Arcade, and the unspent Outputs we spend come from our own wallet, or are handed to us by whoever paid us (see the Architecture overview).

These pages document DartSV 3.1.2. Every code sample you see here is taken from a test that runs against that version.

Terminal window
dart pub add dartsv

In a Flutter project, use flutter pub add dartsv instead. Then import the package:

// import 'package:dartsv/dartsv.dart';
final key = SVPrivateKey(networkType: NetworkType.TEST);
final address = key.toAddress(networkType: NetworkType.TEST);
print('Fund this testnet address: $address');

The Installation page covers SDK versions and the extra packages some of the examples use.

  • Keys and Addresses: Private and Public Keys (WIF, hex), Addresses, HD keys (BIP32), mnemonic seeds (BIP39), Bitcoin Signed Messages and ECIES encryption.
  • Transactions: a TransactionBuilder with fees and change, P2PKH, P2PK, multisig, P2SH and data Outputs, lock time, Sighash types, custom signers, and parsing and serialising.
  • Script: building and parsing scripts, writing your own Locking and Unlocking Script builders, script templates that recognise script types, and a Script Interpreter with the Genesis and Chronicle rules.
  • Blocks and utilities: block headers and blocks, amounts, hashes and variable-length integers.

The concepts behind the API (Transactions, Script, Signatures, Addresses) are explained in the Developer Guide. Rather than repeat that material, these pages link to it.

DartSV is a port of the same design as Bitcoin4J, the TwoStack library for the JVM. The class names and the builder API match closely, so code moves between the two with few changes.

A few APIs in 3.1.2 behave in ways that can trip you up. Each page points out the ones that affect it, along with the behaviour the tests confirm and a way around it.