Generate a BIP39 mnemonic, configure the wallet to use the signet test network, and initialize it.
use std::path::PathBuf;use std::sync::Arc;use tokio::fs;use bark::{Config, onchain, Wallet};use bark::persist::sqlite::SqliteClient;const MNEMONIC_FILE : &str = "mnemonic";const DB_FILE: &str = "db.sqlite";#[tokio::main]async fn main() { // Pick the bitcoin network that will be used let network = bitcoin::Network::Signet; // Configure the wallet let config = Config { server_address: String::from("https://ark.signet.2nd.dev"), esplora_address: Some(String::from("https://esplora.signet.2nd.dev")), ..Config::network_default(network) }; // Create a sqlite database let datadir = PathBuf::from("./bark"); let db = Arc::new(SqliteClient::open(datadir.join(DB_FILE)).unwrap()); // Generate a seed phrase and store it somewhere let mnemonic = bip39::Mnemonic::generate(12).expect("12 is valid"); fs::write(datadir.join(MNEMONIC_FILE), mnemonic.to_string().as_bytes()).await.unwrap(); let wallet = Wallet::create( &mnemonic, network, config, db, false ).await.unwrap();}
Back up the mnemonic securely. It is the only way to recover your wallet.
3
Get a receiving address
Generate an Ark address to receive funds.
let address = wallet.new_address().await?;println!("Ark address: {}", 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.