Appearance
Client
Create one WalletVerificationClient with createWalletVerification. There is no loadSession and no Connect sessionId.
This SDK is browser only. createWalletVerification throws BROWSER_REQUIRED on the server (Node.js, SSR, RSC). In Next.js, instantiate it in a client component ('use client') or a module that only runs in the browser.
ts
import { createWalletVerification } from '@swapped/connect-sdk/wallet-verification'
const client = createWalletVerification({
apiKey: 'your-public-api-key',
environment: 'staging', // omit or 'production' for live
})Reuse this instance for the life of the verification UI. Call destroy() on teardown. Do not create a Connect client (createSwappedConnectClient) for this product, and do not call Connect client.wallets / client.coinbase here.
Config
CreateWalletVerificationConfig:
| Option | Default | Notes |
|---|---|---|
apiKey | - | Required public session API key (WALLET_VERIFICATION_API_KEY_REQUIRED if empty). Same style of key as Connect - not a sessionId |
environment | 'production' | 'production' or 'staging'. Sets default API, WebSocket, and gateway hosts |
apiBaseUrl | environment default | Overrides the API host. Allow-listed to the official production and staging hosts (INVALID_API_BASE_URL otherwise) |
widgetBaseUrl | environment default | Gateway host that serves /gateway. Localhost is allowed for widget development (INVALID_WIDGET_BASE_URL otherwise) |
persistVerification | true | Same-tab Coinbase (mode: 'redirect') only. Keeps the pending verification id in this tab so completeVerification() can recover after Coinbase sends the browser back. New-tab mode does not persist |
Auth is the public API key only. There is no HMAC, session secret, or sessionId.
Environments
The client defaults to production. Pass environment: 'staging' to point the API, WebSocket, and gateway at staging. Use a staging API key against staging.
| Environment | Client |
|---|---|
| Production (default) | omit environment, or environment: 'production' |
| Staging | environment: 'staging' |
Optional apiBaseUrl / widgetBaseUrl replace that environment's defaults. If you pass a custom apiBaseUrl, the client infers environment from it when environment is omitted.
Sites with a Content-Security-Policy must allow the hidden /gateway iframe and the API WebSocket - see Browser requirements. Some wallets and Coinbase also open a tab or popup; a blocked popup is WALLET_POPUP_BLOCKED.
Surface
| Member | What it does |
|---|---|
client.wallets | List wallets and run signature verification (verify() / prepareVerify()) - Verify wallet |
client.coinbase | Coinbase login (startVerification() / openVerificationTab() / completeVerification()) - Coinbase |
client.destroy() | Stop detectors and drop the hidden /gateway iframe when this is the last client using it |
ts
client.destroy()Calling a method after destroy() throws CLIENT_DESTROYED. Create a new client if the user starts again.
Errors
| Code | When | What to do |
|---|---|---|
BROWSER_REQUIRED | Client created outside the browser | Instantiate in a browser-only module |
WALLET_VERIFICATION_API_KEY_REQUIRED | apiKey is missing or blank | Pass the public session API key |
INVALID_ENVIRONMENT | environment is not production or staging | Use one of those two values |
INVALID_API_BASE_URL | apiBaseUrl is not an official host | Use the production or staging API URL, or omit it |
INVALID_WIDGET_BASE_URL | widgetBaseUrl is not official and not localhost | Use the environment default, or a localhost widget host |
CLIENT_DESTROYED | Method called after destroy() | Create a new client |