Skip to content

Getting Started

Note: If your app is still using the CoinbaseWalletSDK class. You can follow the Legacy Setup guide here.

Install @coinbase/wallet-sdk

npm
npm i @coinbase/wallet-sdk

Create a new sdk object

setup.ts
import { createCoinbaseWalletSDK } from '@coinbase/wallet-sdk';
 
export const sdk = createCoinbaseWalletSDK({
    appName: "My App",
    appLogoUrl: "https://example.com/logo.png",
    appChainIds: [8453],
    preference: {
        options: "smartWalletOnly",
        attribution: {
            auto: true,
        }
    },
});
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2724. Expected: // @errors: 2724 Compiler Errors: index.ts [2724] 9 - '"@coinbase/wallet-sdk"' has no exported member named 'createCoinbaseWalletSDK'. Did you mean 'CoinbaseWalletSDK'?

Create a new provider object

provider.ts
// @filename: setup.ts
import { createCoinbaseWalletSDK } from '@coinbase/wallet-sdk';
 
export const sdk = createCoinbaseWalletSDK({
    appName: "My App",
    appLogoUrl: "https://example.com/logo.png",
    appChainIds: [8453],
    preference: {
        options: "smartWalletOnly",
        attribution: {
            auto: true,
        }
    },
});
// @filename: example.js
 
// ---cut---
import { sdk } from './setup'
 
// Create provider
export const provider = sdk.getProvider();
// Use provider
const addresses = provider.request({method: 'eth_requestAccounts'});
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2724. Expected: // @errors: 2724 Compiler Errors: setup.ts [2724] 32 - '"@coinbase/wallet-sdk"' has no exported member named 'createCoinbaseWalletSDK'. Did you mean 'CoinbaseWalletSDK'?

Parameters

appName (optional)

  • Type: string

The app name. This will be displayed to users on connection, transacting, and signing requests.

appChainIds (optional)

  • Type: number[]

Array of chain IDs your app supports. Default value is [1].

What networks are supported?

appLogoUrl (optional)

  • Type: string

App logo image URL. Favicon is used if unspecified.

preference (optional)

  • Type Preference
type Attribution = {
    auto: boolean;
    dataSuffix?: never;
} | {
    auto?: never;
    dataSuffix: `0x${string}`;
}
 
type Preference = {
    options?: 'all' | 'smartWalletOnly' | 'eoaOnly';
    attribution?: Attribution;
}

preference.options (optional)

  • Type: 'all' | 'smartWalletOnly' | 'eoaOnly'

Determines which connection options users will see. Defaults to all.

all

Users will see Smart Wallet and mobile app connection options.

smartWalletOnly

With this option, users will only see an option to create a Smart Wallet or sign into their Smart Wallet.

eoaOnly

With this option, users will only see an option to connect with their EOA.

preference.attribution (optional)

  • Type: Attribution

This option only applies to Coinbase Smart Wallet. When a valid data suffix is supplied, it is appended to the initCode and executeBatch calldata.

type Attribution = {
    auto: boolean;
    dataSuffix?: never;
} | {
    auto?: never;
    dataSuffix: `0x${string}`;
}
auto (optional)
  • Type: boolean

If auto is true, the Smart Wallet will generate a 16 byte hex string from the apps origin.

dataSuffix (optional)
  • Type: 0x${string}

Smart Wallet expects a 16 byte hex string. If the data suffix is not a 16 byte hex string, the Smart Wallet will ignore the property.