Skip to main content
The wallet stores its data in two repositories:
  • The wallet repository stores virtual outputs, onchain outputs, transaction history, and wallet settings.
  • The contract repository stores the contracts that the wallet watches.
Pass both repositories to Wallet.create in the storage option. If you omit storage, the wallet uses IndexedDB. Node.js and React Native don’t provide IndexedDB, so pass storage there.
Repositories don’t store the wallet identity. Keep the mnemonic or seed in your platform’s secure storage.

Choose a repository

The examples on this page assume that you set up identity and the providers as in Create your Wallet, or as in Expo/React Native for React Native apps. storage also accepts intentRepository, which tracks your batch registration requests, and virtualTxRepository. Both are optional and experimental.

IndexedDB

The IndexedDB repositories use a database named arkade-service-worker by default. To use a different database, pass its name to each repository:
SDK 0.5 upgrades the IndexedDB database to a new schema the first time it opens it. The upgrade is one way. An older SDK version can’t open the upgraded database: its reads return no data, and its writes fail with VersionError.

SQLite

The SQLite repositories work with any SQLite driver. You connect your driver through a SQLExecutor: an object with three async methods, run, get, and all. The SDK creates its tables on first use. You own the database connection, and the SDK never closes it. Give both repositories the same executor object: the SDK runs one transaction at a time for each executor, and SQLite can’t nest transactions on one connection. The Node.js example uses the built-in node:sqlite module, which is stable from Node.js 22.13.0. The Expo example uses expo-sqlite. In Node.js, also do these two steps, whichever repository you use:
  • Call configureEventSource before Wallet.create. Node.js has no EventSource by default. Without one, boarding, renewal, and offboarding throw EventSourceUnavailableError. The example gets an EventSource from the eventsource package (pnpm add eventsource).
  • Call await wallet.dispose() when you are done with the wallet. It stops the wallet’s background work, so the process can exit. It doesn’t close the database: close it yourself after dispose() resolves. See Shut Down the Wallet.

Table prefix

The SQLite repositories add the prefix ark_ to every table name. To keep more than one wallet in the same database, give each wallet its own prefix. A prefix can contain only letters, digits, and underscores, and it can’t start with a digit.

Realm

The Realm repositories take an open Realm instance. When you open the Realm:
  • Add ArkRealmSchemas to the schema list.
  • Set schemaVersion to ARK_REALM_SCHEMA_VERSION or higher.
  • Call runArkRealmMigrations in onMigration.

In-memory

The in-memory repositories keep data only in memory. The data is lost when the process exits. Use them for tests and short-lived scripts.

Migrate from storage adapters

SDK 0.4 deprecates the storage adapters, and SDK 0.5 removes them. SDK 0.5 also removes migrateWalletRepository and rollbackMigration, which this section uses. Migrate your data on SDK 0.4, then upgrade to 0.5.
Replace each storage adapter with a repository: To keep the data that an adapter stored, copy it to the new wallet repository with migrateWalletRepository. Give it the addresses to copy: boarding addresses in onchain, and Arkade addresses in offchain. The function does nothing if there is no data to migrate or if the migration is already done. It never deletes the old data.
migrateWalletRepository copies wallet data only. Packages that store their own contract data supply their own migration, for example migrateToSwapRepository in @arkade-os/boltz-swap.