Use this prompt to get started quickly.
Prerequisites
- A modern browser with WebAssembly, IndexedDB, and the Web Locks API
- A secure context: served over HTTPS or
localhost - For the bundler setups: a bundler that can emit a
.wasmasset, such as Vite, webpack, or Next.js
Getting started
1
Install the SDK
- Vite
- Next.js
- Vanilla HTML/JS
@secondts/bark/web subpath and pass the URL of the .wasm binary to init().The only bundler-specific line is how you get that URL:- Vite:
import wasmUrl from "@secondts/bark/web/bark_ffi_wasm_bg.wasm?url" - webpack / Next.js:
new URL("@secondts/bark/web/bark_ffi_wasm_bg.wasm", import.meta.url) - Fallback (any): Copy
bark_ffi_wasm_bg.wasminto your static assets folder, such aspublic/, and pass its path asmodule_or_path, for exampleinit({ module_or_path: "/bark_ffi_wasm_bg.wasm" }).
2
Create a wallet
Instantiate the WebAssembly module, generate a BIP39 mnemonic, and open the wallet on signet.
Wallet.open() creates the wallet in IndexedDB on the first visit and reopens it on later ones.- Vite
- Next.js
- Vanilla HTML/JS
3
Get a receiving address
Generate an Ark address to receive bitcoin.Load your page to log the address in the browser’s developer console. Send some signet sats to this address using the faucet.
4
Check your balance
Bark syncs the wallet in the background for as long as your page holds a reference to the Balance amounts are
Wallet object. Call sync() when you need an up-to-date balance right away.number values.Reload the page. It reopens the same wallet and logs your spendable balance in sats.Next steps
Source code
Web bindings package source on GitLab.
How Ark works
Learn about the protocol powering your wallet.