CoinbaseWalletSDK Changes (v3 to v4)
This page details changes between versions 3.x and 4.x of the Coinbase Wallet SDK.
CoinbaseWalletSDK
CoinbaseWalletSDKOptions
// v4
type CoinbaseWalletSDKOptions = {
appName?: string | undefined;
appLogoUrl?: string | null | undefined;
appChainIds?: number[] | undefined;
};
New (v4 only):
appChainIds?: number[]
- An array of chain IDs your dapp supports
- The first chain in this array will be used as the default chain.
- Removes the need for non-mainnet dapps to request switching chains before making first request.
- Default value is
[1]
(mainnet)
Deprecated (v3 only):
enableMobileWalletLink
(enabled by default in v4)jsonRpcUrl
reloadOnDisconnect
uiConstructor
overrideIsMetaMask
overrideIsCoinbaseWallet
diagnosticLogger
reloadOnDisconnect
headlessMode
Deprecated functions
CoinbaseWalletSDK.disconnect()
is deprecated- dapps should call
CoinbaseWalletProvider.disconnect()
instead
- dapps should call
CoinbaseWalletSDK.setAppInfo()
is deprecated- Dapps should pass in
appName
andappLogoUrl
viaCoinbaseWalletSDKOptions
- Dapps should pass in
makeWeb3Provider
Signature
// v3
makeWeb3Provider(jsonRpcUrl?: string, chainId?: number): CoinbaseWalletProvider
// v4
makeWeb3Provider(preference: Preference = { options: 'all' }): ProviderInterface
Parameters
interface Preference {
options: 'all' | 'smartWalletOnly' | 'eoaOnly';
}
options
'all'
(default) show both smart wallet and EOA options'smartWalletOnly'
only show smart wallet option'eoaOnly'
only show EOA option
Return type
export interface ProviderInterface extends EventEmitter {
request<T>(args: RequestArguments): Promise<T>;
disconnect(): Promise<void>;
on(event: 'connect', listener: (info: ProviderConnectInfo) => void): this;
on(event: 'disconnect', listener: (error: ProviderRpcError) => void): this;
on(event: 'chainChanged', listener: (chainId: string) => void): this;
on(event: 'accountsChanged', listener: (accounts: string[]) => void): this;
on(event: 'message', listener: (message: ProviderMessage) => void): this;
}
CoinbaseWalletProvider
connect
event fix
- v3 returned
chainIdStr
instead ofchainId
. - v4 is EIP-1193 compliant.
// v4
interface ProviderConnectInfo { readonly chainId: string; }
on(event: 'connect', listener: (info: ProviderConnectInfo) => void): this;
eth_accounts
when disconnected
- v3 returned an empty array.
- v4 throws an error.
Error: Must call 'eth_requestAccounts' before other methods
Deprecated functionality
Instance properties
isCoinbaseBrowser: boolean
qrUrl?: string | null
reloadOnDisconnect: boolean
Getter methods
selectedAddress
networkVersion
isWalletLink
ismetaMask
host
Methods
disableReloadOnDisconnect
setProviderInfo
setAppInfo
close
send
sendAsync
scanQRCode
genericRequest
connectAndSignIn
selectProvider
supportsSubscriptions
subscribe
unsubscribe