Skip to content

Coinbase example ​

End-to-end Coinbase verification: create a client, start OAuth, finish in a new tab or same-tab redirect, read the result.

The address lives on Coinbase.com. There is no wallet connect and no signature step. For a self-custodial wallet, see Wallets example.

This is not a Connect session. You need a public API key, not a sessionId. customerId is your id for the end user. Do not reuse Connect client.coinbase.

1. Create the client ​

ts
import { createWalletVerification } from '@swapped/connect-sdk/wallet-verification'

const client = createWalletVerification({
  apiKey: 'your-public-api-key',
  environment: 'staging',
})

See Client. Call destroy() when the page tears down.

2. New tab ​

Create the record, then open Coinbase from a click so the browser does not block the tab.

ts
await client.coinbase.startVerification({
  address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
  network: 'evm',
  customerId: 'user-1234',
})

const verification = await client.coinbase.openVerificationTab()

mode defaults to 'new-tab'. If customerId + address is already verified, startVerification() returns status: 'verified' immediately - no tab.

3. Same-tab redirect ​

startVerification() navigates this tab to Coinbase. Host a landing page at redirectUrl and finish there.

ts
await client.coinbase.startVerification({
  address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
  network: 'evm',
  customerId: 'user-1234',
  mode: 'redirect',
  redirectUrl: 'https://merchant.example.com/wallet-verified',
})

// on the landing page
const verification = await client.coinbase.completeVerification()

Treat ?status= as a hint only - use the returned record.

4. Read the result ​

ts
if (verification.status === 'verified') {
  verification.verificationId
  verification.address
  verification.verifiedAt
}

if (verification.status === 'failed' || verification.status === 'expired') {
  // start a new startVerification()
}

See Result.

5. Tear down ​

ts
client.destroy()

See Coinbase for modes, cancel, and errors.

Deep dives: Client, Coinbase, Result, Errors.