Skip to main content
React Native has no EventSource and no crypto.getRandomValues(). In an Expo app, polyfill crypto.getRandomValues(), connect through the SDK’s Expo providers, and store the wallet’s data in SQLite.

Installation

Crypto Polyfill Setup

You must polyfill crypto.getRandomValues() before importing the SDK. This is required for MuSig2 settlements and cryptographic operations.
Add this at the top of your app entry point (before any SDK imports):

Basic Setup

Create a wallet with Expo-compatible providers and SQLite storage:

Background Sync

Wallet.create keeps the wallet in sync only while the app is open. To keep syncing while the app is closed, create the wallet with ExpoWallet.setup and register a background task. This needs Expo SDK 54 or later.
Call defineExpoBackgroundTask at module scope, before React mounts. Expo can then resume the task when the OS starts the app in the background. Import the module below at the top level of your app.
With this module, the wallet stays in sync in two ways:
  • While the app is open, ExpoWallet checks the wallet’s contracts every foregroundIntervalMs (20 seconds here).
  • While the app is closed, the OS runs the background task at most every 15 minutes, the minimum interval of expo-background-task. The OS decides when the task actually runs.
The background task updates the stored outputs of the wallet’s contracts. It doesn’t renew outputs: renewal runs only while the app is open.

Storage

Repositories don’t store the identity. Keep the mnemonic in secure storage, such as expo-secure-store. Apps that use Realm can pass the Realm repositories instead of SQLite.

Common Issues

Crypto Not Defined

Error: crypto is not defined or crypto.getRandomValues is not a function Solution: Set up the crypto polyfill before the first SDK import.

EventSource Not Available

Error: EventSource is not defined Solution: Pass ExpoArkProvider and ExpoIndexerProvider to Wallet.create, as in Basic Setup.

Testing on Devices

localhost doesn’t reach the operator from a physical device. Use a reachable URL, such as the public instances in Developer Resources.