The browser entry point has the same RailgunClient methods as Node. The
difference is storage: you open the databases and pass the storages to
create().
npm add @railgun-reloaded/wallet-sdk @railgun-reloaded/storage @sqlite.org/sqlite-wasm viem
import {
createChainDB,
createChainStorage,
createWalletDB,
createWalletStorage
} from '@railgun-reloaded/storage/browser'
import { RailgunClient } from '@railgun-reloaded/wallet-sdk/browser'
const chainDB = await createChainDB({ name: 'railgun-chain-8453', waitForLock: true })
const walletDB = await createWalletDB({ name: 'railgun-wallets', waitForLock: true })
const client = await RailgunClient.create({
chainStorages: { 8453: createChainStorage(chainDB) },
walletStorage: createWalletStorage(walletDB)
})
chainStorages. A call for a chain with no
entry throws.client.close().waitForLock: true makes a second tab wait for the first tab to release the
database.| Node | Browser | |
|---|---|---|
create() options |
dataDir, or injected walletDB and chainDBs |
chainStorages and walletStorage, required |
| Database owner | The client, unless injected | The caller |
| Snapshot bootstrap helpers | Yes | No |
The rest of the API is the same. The guides use the Node import. Change the
import path to @railgun-reloaded/wallet-sdk/browser for the browser.