Appearance
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
mode | What 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
| Field | Meaning |
|---|---|
startVerification | Create the Coinbase record. In redirect mode this also navigates this tab to Coinbase |
openVerificationTab | From a click: open Coinbase in a new tab and wait on this page until verified / failed / expired |
completeVerification | On the redirect landing page: load the record (from the argument, ?verificationId=, or persisted id) |
cancelVerification | Close the Coinbase tab and stop isWaiting (WALLET_VERIFICATION_CANCELLED) |
isStarting | true while startVerification() is creating the record (or navigating away in redirect mode) |
isWaiting | true while openVerificationTab() is in flight - the Coinbase tab is open and this page is waiting for it to finish |
isCompleting | true while completeVerification() is resolving the landing-page record |
verification | The WalletVerification from the last successful start / open / complete, or null |
error | Error from the last failed start / open / complete, or null |
Mode details: Core Coinbase. Walkthrough: Coinbase example.