Skip to main content

Use this prompt to get started quickly.

CursorOpen in Cursor

Prerequisites

  • Go 1.19+
  • CGo enabled (default)
  • C compiler (gcc, clang, or MSVC)

Getting started

1

Install the SDK

go get gitlab.com/ark-bitcoin/bark-ffi-bindings/golang/bark@v0.1.1-beta.1+bark.0.1.0-beta.7
2

Create a wallet

Generate a BIP39 mnemonic, configure the wallet for signet, and initialize it.
package main

import (
    "fmt"
    "os"
    "path/filepath"

    "gitlab.com/ark-bitcoin/bark-ffi-bindings/golang/bark"
)

func main() {
    // Generate a new mnemonic
    mnemonic, err := bark.GenerateMnemonic()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }
    fmt.Printf("Mnemonic: %s\n", mnemonic)

    // Helper for optional string fields
    strPtr := func(s string) *string { return &s }

    // Configure for signet
    config := bark.Config{
        ServerAddress:  "https://ark.signet.2nd.dev",
        EsploraAddress: strPtr("https://esplora.signet.2nd.dev"),
        Network:        bark.NetworkSignet,
    }

    // Create a data directory
    homeDir, _ := os.UserHomeDir()
    dataDir := filepath.Join(homeDir, ".bark", "my_wallet")
    os.MkdirAll(dataDir, 0755)

    // Create the wallet
    wallet, err := bark.WalletCreate(mnemonic, config, dataDir, false)
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }
    defer wallet.Destroy()
}
Back up the mnemonic securely. It is the only way to recover your wallet.
You must call wallet.Destroy() when you are done with the wallet to free the underlying Rust resources. Use defer wallet.Destroy() immediately after creation.
3

Get a receiving address

Generate an Ark address to receive funds.
address, err := wallet.NewAddress()
if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    os.Exit(1)
}
fmt.Printf("Ark address: %s\n", address)
Send some signet sats to this address using the faucet.
4

Check your balance

Sync the wallet with the Ark server and read your balance.
if err := wallet.Sync(); err != nil {
    fmt.Fprintf(os.Stderr, "Sync error: %v\n", err)
    os.Exit(1)
}

balance, err := wallet.Balance()
if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    os.Exit(1)
}
fmt.Printf("Spendable: %d sats\n", balance.SpendableSats)

Next steps