Skip to content

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:

OptionDefaultNotes
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
apiBaseUrlenvironment defaultOverrides the API host. Allow-listed to the official production and staging hosts (INVALID_API_BASE_URL otherwise)
widgetBaseUrlenvironment defaultGateway host that serves /gateway. Localhost is allowed for widget development (INVALID_WIDGET_BASE_URL otherwise)
persistVerificationtrueSame-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.

EnvironmentClient
Production (default)omit environment, or environment: 'production'
Stagingenvironment: '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 ​

MemberWhat it does
client.walletsList wallets and run signature verification (verify() / prepareVerify()) - Verify wallet
client.coinbaseCoinbase 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 ​

CodeWhenWhat to do
BROWSER_REQUIREDClient created outside the browserInstantiate in a browser-only module
WALLET_VERIFICATION_API_KEY_REQUIREDapiKey is missing or blankPass the public session API key
INVALID_ENVIRONMENTenvironment is not production or stagingUse one of those two values
INVALID_API_BASE_URLapiBaseUrl is not an official hostUse the production or staging API URL, or omit it
INVALID_WIDGET_BASE_URLwidgetBaseUrl is not official and not localhostUse the environment default, or a localhost widget host
CLIENT_DESTROYEDMethod called after destroy()Create a new client