Skip to main content
Version: 3.0.0

Smart Wallet Setup

This page explains how to prepare for a Coinbase smart wallet launch with Coinbase Wallet SDK v4 Beta or RC.

Choose version

Before installing, decide which version 4 release channel is right for you.

Beta

npm i @coinbase/wallet-sdk@4.0.0-beta.12
  • Use this to test smart wallet on testnet across any domain.
  • Test smart wallet features on Base Sepolia so you can prepare a smart-wallet UX to offer to your users on day 1.
  • Base sepolia only.
  • Works on any dapp domain.

RC

npm i @coinbase/wallet-sdk@4.0.0-rc.1
  • Use this in production to ensure that you're ready for mainnet smart wallets on day 1.
  • Use to test smart wallet features on mainnet locally. Smart wallet connectivity is available prior to mainnet launch when dapp domain is localhost, but is blocked for other domains.
  • Connecting via the wallet extension or mobile app is allowed on all domains.
  • When mainnet launch occurs, smart wallet functionality will be switched on for all dapp domains.

Install or upgrade

Use the version number from the latest beta or rc release, depending on your needs:

  
{
"dependencies": {
"@coinbase/wallet-sdk": "<latest beta or rc version>"
}
}

Initialize

1. Initialize SDK

// Initialize Coinbase Wallet SDK
export const coinbaseWalletSdk = new CoinbaseWalletSDK({
appName: "An Awesome App",
appChainIds: [84532],
});

2. Make web3 provider

const provider = coinbaseWalletSdk.makeWeb3Provider();

3. Initialize wallet connection

To initialize a wallet connection, you can request accounts:

const addresses = provider.request("eth_requestAccounts");
  • When provider.request("eth_requestAccounts") is called to initialize the connection, a Coinbase wallet popup opens allowing the end user to create a smart wallet, sign in to an existing smart wallet via passkey, or connect with their mobile wallet via QR code scan.
info

Users with the Coinbase wallet extension installed are prompted to connect that way. Disable the extension to try connecting with a smart wallet.

Make more requests

For example RPC requests, see the ethereum spec.

Handle provider events

provider.on('connect', (info) => {
setConnect(info);
});

provider.on('disconnect', (error) => {
setDisconnect({ code: error.code, message: error.message });
});

provider.on('accountsChanged', (accounts) => {
setAccountsChanged(accounts);
});

provider.on('chainChanged', (chainId) => {
setChainChanged(chainId);
});

provider.on('message', (message) => {
setMessage(message);
});

Was this helpful?