Skip to main content

Prerequisites

  • Node.js 22.13 to 26

Installation

Basic Setup

A mnemonic, a phrase of 12 words, controls the wallet and its funds. Generate it once, in your project folder:
Store the mnemonic securely: anyone who has it can spend the funds. The examples in these docs read it from the ARKADE_MNEMONIC environment variable. In production, load it from your platform’s secure storage, and never log it.
In Node.js, add three steps. The wallet stores its data in IndexedDB by default, and Node.js has no IndexedDB. Node.js also has no EventSource by default.
  • Pass a storage option to Wallet.create. Without it, the wallet can’t save its data, and reads such as getBalance() throw.
  • Call configureEventSource before Wallet.create. Without it, boarding, renewal, and offboarding throw.
  • Call await wallet.dispose() when your script is done. Without it, the script never exits. See Shut Down the Wallet.
For a complete Node.js setup, see Storage Repositories.

Shut Down the Wallet

Wallet.create starts background work that keeps running until you call dispose():
  • The VtxoManager, which renews and recovers outputs and settles boarding deposits.
  • Contract watching, and the wallet’s subscriptions to the operator.
await wallet.dispose() stops all of it. It first lets work already in progress finish, such as a restore or a renewal check, so it may not resolve immediately. Call it once, when your app or script no longer needs the wallet:
  • In Node.js, call it before the process should exit. The open subscriptions and timers keep the process alive.
  • In an app, call it when the user logs out or switches wallets.
After dispose(), the wallet no longer renews outputs. To use the wallet again, create a new instance with Wallet.create. dispose() doesn’t close your storage. If you passed SQLite or Realm repositories, you own the connection: close it after dispose() resolves. wallet.clear() calls dispose() itself before it wipes the wallet’s data. Wallet also implements Symbol.asyncDispose. If your toolchain supports explicit resource management, await using calls dispose() when the variable goes out of scope:
ReadonlyWallet has the same dispose() method.

Next Steps