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.
Use this prompt to get started quickly.
Prerequisites
- iOS 13+ or macOS 12+
- Swift 5.9+, Xcode 15+
Getting started
Install the SDK
In Xcode, go to File > Add Package Dependencies and enter:https://gitlab.com/ark-bitcoin/bark-ffi-bindings
Add the dependency to your Package.swift:dependencies: [
.package(
url: "https://gitlab.com/ark-bitcoin/bark-ffi-bindings",
exact: "0.3.0+bark.0.1.1"
)
]
Then add "Bark" to your target’s dependencies:.target(
name: "YourApp",
dependencies: [
.product(name: "Bark", package: "bark-ffi-bindings")
]
)
Create a wallet
Generate a BIP39 mnemonic, configure the wallet for signet, and initialize it.import Bark
import Foundation
// Generate a new mnemonic
let mnemonic = generateMnemonic()
print("Mnemonic: \(mnemonic)")
// Create a data directory
let dataDir = FileManager.default.temporaryDirectory
.appendingPathComponent("bark_wallet")
try FileManager.default.createDirectory(
at: dataDir, withIntermediateDirectories: true
)
// Configure for signet
let config = Config(
serverAddress: "https://ark.signet.2nd.dev",
esploraAddress: "https://esplora.signet.2nd.dev",
bitcoindAddress: nil,
bitcoindCookiefile: nil,
bitcoindUser: nil,
bitcoindPass: nil,
network: .signet,
vtxoRefreshExpiryThreshold: nil,
vtxoExitMargin: nil,
htlcRecvClaimDelta: nil,
fallbackFeeRate: nil,
roundTxRequiredConfirmations: nil,
daemonFastSyncIntervalSecs: nil,
daemonSlowSyncIntervalSecs: nil
)
// Create the wallet
let wallet = try await Wallet.create(
mnemonic: mnemonic,
config: config,
datadir: dataDir.path,
forceRescan: false
)
Back up the mnemonic securely. It is the only way to recover your wallet.
open is a reserved keyword in Swift. If you need to load an existing wallet, use backticks: try await Wallet.`open`(mnemonic:config:datadir:).
Get a receiving address
Generate an Ark address to receive funds.let address = try await wallet.newAddress()
print("Ark address: \(address)")
Send some signet sats to this address using the faucet. Check your balance
Sync the wallet with the Ark server and read your balance.try await wallet.sync()
let balance = try await wallet.balance()
print("Spendable: \(balance.spendableSats) sats")
Next steps
Source and examples
Full Swift source and example projects on GitLab.
How Ark works
Learn about the protocol powering your wallet.