> ## Documentation Index
> Fetch the complete documentation index at: https://second.tech/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with Dart

> Add Ark payments to your Dart or Flutter app. Create a wallet, generate addresses, and check your balance in minutes.

<Prompt description="Use this prompt to get started quickly." icon="microchip" iconType="solid" actions={["copy", "cursor"]}>
  # Bark Dart SDK

  Build Ark wallet apps with the `bark_bitcoin` Dart package. Ark is a Bitcoin layer 2 protocol for instant, low-fee, self-custodial payments.

  ## Prerequisites

  * Dart SDK 3.11+ / Flutter 3.x+
  * Rust toolchain (`rustup`, `cargo`, `rustc`). Required because the package compiles its Rust core at build time using Dart's Native Assets feature.

  ## Install

  ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  dart pub add bark_bitcoin
  # or
  flutter pub add bark_bitcoin
  ```

  Then run `dart pub get`.

  To get the data directory path, we also recommend installing `path_provider` package.

  ## Create a wallet

  ```dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import 'dart:io';
  import 'package:bark_bitcoin/bark_bitcoin.dart';
  import 'package:path_provider/path_provider.dart';

  const _barkDir = '.bark';

  final documentsDir = await getApplicationDocumentsDirectory();
  final dataDir = Directory('${documentsDir.path}/$_barkDir');
  final mnemonic = generateMnemonic();
  final config = Config(
    serverAddress: "https://ark.signet.2nd.dev",
    esploraAddress: "https://esplora.signet.2nd.dev",
    bitcoindAddress: null,
    bitcoindCookiefile: null,
    bitcoindUser: null,
    bitcoindPass: null,
    network: Network.signet,
    vtxoRefreshExpiryThreshold: null,
    vtxoExitMargin: null,
    htlcRecvClaimDelta: null,
    fallbackFeeRate: null,
    roundTxRequiredConfirmations: null,
    daemonFastSyncIntervalSecs: null,
    daemonSlowSyncIntervalSecs: null,
  );
  final wallet = await Wallet.create(
    mnemonic: mnemonic,
    config: config,
    datadir: dataDir.path,
    forceRescan: false,
  );
  ```

  ## Get address and check balance

  ```dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
  final address = await wallet.newAddress();
  await wallet.sync_();  // trailing underscore: sync is a reserved keyword in Dart
  final balance = await wallet.balance();
  print("${balance.spendableSats} sats");
  ```

  ## Signet test environment

  * Ark server: [https://ark.signet.2nd.dev](https://ark.signet.2nd.dev)
  * Block explorer (Esplora): [https://esplora.signet.2nd.dev](https://esplora.signet.2nd.dev)
  * Faucet for test bitcoin: [https://signet.2nd.dev/](https://signet.2nd.dev/)
  * Network enum: `Network.signet`

  ## Rules

  * The sync method is `sync_()` with a trailing underscore. `sync` is a reserved keyword in Dart.
  * The `Config` constructor uses named parameters.
  * Wallet operations are asynchronous—use `async`/`await`.
  * A Rust toolchain must be installed on the development machine for the native build step.
  * Use `Network.signet` for testing. Never use mainnet without user confirmation.
  * Never hardcode mnemonics in production code.
  * Correct terminology: Ark (not ARC), VTXO (not vtxo), on-chain (not onchain), off-chain (not offchain).
  * "Bark" (capitalized) in prose, "bark" (lowercase) for the package name and CLI commands.
</Prompt>

## Prerequisites

* Dart SDK 3.11+ / Flutter 3.x+
* Rust toolchain (`rustup`, `cargo`, `rustc`). The `bark_bitcoin` package compiles its Rust core at build time using Dart's [Native Assets](https://dart.dev/interop/c-interop#native-assets) feature.

## Getting started

<Steps>
  <Step title="Install the SDK">
    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    dart pub add bark_bitcoin
    ```

    Then run:

    ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
    dart pub get
    ```
  </Step>

  <Step title="Create a wallet">
    Configure the wallet for signet and initialize it.

    ```dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
    import 'dart:io';
    import 'package:bark_bitcoin/bark_bitcoin.dart';

    Future<void> main() async {
      // Use a known test mnemonic (generate your own for real use)
      final mnemonic =
          "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";

      // Configure for signet
      final config = Config(
        serverAddress: "https://ark.signet.2nd.dev",
        esploraAddress: "https://esplora.signet.2nd.dev",
        bitcoindAddress: null,
        bitcoindCookiefile: null,
        bitcoindUser: null,
        bitcoindPass: null,
        network: Network.signet,
        vtxoRefreshExpiryThreshold: null,
        vtxoExitMargin: null,
        htlcRecvClaimDelta: null,
        fallbackFeeRate: null,
        roundTxRequiredConfirmations: null,
        daemonFastSyncIntervalSecs: null,
        daemonSlowSyncIntervalSecs: null,
      );

      // Create a data directory
      final dataDir = Directory('./bark_db');
      dataDir.createSync(recursive: true);

      // Create the wallet
      final wallet = await Wallet.create(
        mnemonic: mnemonic,
        config: config,
        datadir: dataDir.path,
        forceRescan: false,
      );
    }
    ```

    <Note>
      Back up the mnemonic securely. It is the only way to recover your wallet.
    </Note>
  </Step>

  <Step title="Get a receiving address">
    Generate an Ark address to receive funds.

    ```dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
    final address = await wallet.newAddress();
    print("Ark address: $address");
    ```

    Send some signet sats to this address using [the faucet](https://signet.2nd.dev/).
  </Step>

  <Step title="Check your balance">
    Sync the wallet with the Ark server and read your balance.

    <Warning>
      `sync` is a reserved keyword in Dart. The method is named `sync_()` with a trailing underscore.
    </Warning>

    ```dart theme={"theme":{"light":"github-light","dark":"github-dark"}}
    await wallet.sync_();

    final balance = await wallet.balance();
    print("Spendable: ${balance.spendableSats} sats");
    ```
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Source and examples" icon="https://mintcdn.com/second-0659a37d/IZIYL7kfKRS394NE/images/gitlab-icon-outline.svg?fit=max&auto=format&n=IZIYL7kfKRS394NE&q=85&s=31497d40e3e7174b42f13799a0b33eb5" href="https://gitlab.com/ark-bitcoin/bark-ffi-bindings/-/tree/master/dart" width="192" height="192" data-path="images/gitlab-icon-outline.svg">
    Full Dart source and example projects on GitLab.
  </Card>

  <Card title="How Ark works" icon="graduation-cap" href="/learn/intro">
    Learn about the protocol powering your wallet.
  </Card>
</CardGroup>
