Skip to main content

Use this prompt to get started quickly.

Open in Cursor
These examples connect to signet so you can test for free. To go live, point the same configuration at Second’s mainnet endpoints from Connection details and select the mainnet network.

Prerequisites

  • Go 1.19+
  • A C compiler on your PATH for cgo: GCC or Clang, or MinGW-w64 GCC on Windows
  • macOS 14+ (Intel or Apple silicon), Linux (x86-64 or ARM64) with glibc 2.34+, or Windows (x86-64)

Getting started

1

Install the SDK

In your module’s directory, run:
On macOS, also set this variable in the terminal you build from:
2

Create a wallet

Generate a BIP39 mnemonic, configure the signet endpoints, and open the wallet in a data directory. With CreateIfNotExists: true, bark.WalletOpen() creates the wallet on the first launch and reopens it on later ones.Set CreateIfNotExists and RunDaemon to true, as in the sample. Go sets every bool field you leave out to false.
main.go
Run it with go run . from your module’s directory. If the build fails with undefined: BarkLogger, cgo is off. Put a C compiler on your PATH, check that go env CGO_ENABLED prints 1, and run it again.
The sample code stores the mnemonic in an unencrypted file so that the next launch reopens the same wallet. That is acceptable for signet tests only. In a production app, store the mnemonic in your platform’s secure storage. Also set up continuous wallet data backups, so users can restore their wallet without the Ark server’s cooperation.
3

Get a receiving address

Generate an Ark address to receive bitcoin. Add this code at the end of run(), before return nil:
Run go run . to print the address. Send some signet sats to this address using the faucet.
4

Check your balance

With RunDaemon: true, Bark syncs the wallet in the background while it’s open. Call Sync() when you need an up-to-date balance right away. Add this code after the address code, before return nil:
Balance amounts are uint64 values.Run go run . again. The program reopens the same wallet and prints your spendable balance in sats.

Next steps

Source code

Go bindings source on GitLab.

How Ark works

Learn about the protocol powering your wallet.