Skip to content

useCoinbaseVerification ​

useCoinbaseVerification() proves the user controls an address that lives on Coinbase. The user signs in; Swapped confirms the address. There is no wallet connect and no signature step.

address, network, and customerId default to provider identity. address is required.

Do not reuse Connect useCoinbaseConnection (that hook withdraws to a session).

Modes ​

modeWhat happens
'new-tab' (default)startVerification() creates the record only. From a click, call openVerificationTab() to open Coinbase and wait on this page
'redirect'startVerification() creates the record and navigates this tab to Coinbase. On the landing page, call completeVerification() yourself

If that customerId + address is already verified, startVerification() returns status: 'verified' immediately - no tab and no redirect.

New tab ​

Split create and open so the Coinbase tab comes from a user gesture (otherwise the browser blocks it).

tsx
import { useCoinbaseVerification } from '@swapped/connect-sdk/wallet-verification/react'

function CoinbaseVerify() {
  const {
    startVerification,
    openVerificationTab,
    cancelVerification,
    isStarting,
    isWaiting,
    error,
  } = useCoinbaseVerification()

  return (
    <>
      <button
        type="button"
        disabled={isStarting}
        onClick={() => void startVerification({ mode: 'new-tab' })}
      >
        Start
      </button>
      <button
        type="button"
        disabled={isWaiting}
        onClick={() => void openVerificationTab()}
      >
        Open Coinbase
      </button>
      <button type="button" onClick={cancelVerification}>
        Cancel
      </button>
      {error ? <p>{error.message}</p> : null}
    </>
  )
}

openVerificationTab() must stay in a click handler. Failures: WALLET_VERIFICATION_NOT_STARTED, WALLET_POPUP_BLOCKED, WALLET_VERIFICATION_CANCELLED.

Same-tab redirect ​

The hook does not call completeVerification() on mount. Do it on the landing page:

tsx
await startVerification({
  mode: 'redirect',
  redirectUrl: 'https://merchant.example.com/wallet-verified',
})

// on the landing page
const { completeVerification } = useCoinbaseVerification()
const verification = await completeVerification()

redirect without redirectUrl throws WALLET_VERIFICATION_REDIRECT_URL_REQUIRED. Treat ?status= as a hint only - use the returned record.

Returns ​

FieldMeaning
startVerificationCreate the Coinbase record. In redirect mode this also navigates this tab to Coinbase
openVerificationTabFrom a click: open Coinbase in a new tab and wait on this page until verified / failed / expired
completeVerificationOn the redirect landing page: load the record (from the argument, ?verificationId=, or persisted id)
cancelVerificationClose the Coinbase tab and stop isWaiting (WALLET_VERIFICATION_CANCELLED)
isStartingtrue while startVerification() is creating the record (or navigating away in redirect mode)
isWaitingtrue while openVerificationTab() is in flight - the Coinbase tab is open and this page is waiting for it to finish
isCompletingtrue while completeVerification() is resolving the landing-page record
verificationThe WalletVerification from the last successful start / open / complete, or null
errorError from the last failed start / open / complete, or null

Mode details: Core Coinbase. Walkthrough: Coinbase example.