Legacy class-based SDK interface maintained for backwards compatibility. New projects should use createCoinbaseWalletSDK instead.
Legacy class-based SDK initialization and provider creation.
/**
* @deprecated CoinbaseWalletSDK is deprecated and will likely be removed in a future major version release.
* It's recommended to use `createCoinbaseWalletSDK` instead.
*/
class CoinbaseWalletSDK {
/**
* Initialize legacy SDK instance
* @param metadata - App metadata configuration (partial)
*/
constructor(metadata: Readonly<CoinbaseWalletSDKOptions>);
/**
* Create Web3 provider instance
* @param preference - Optional wallet connection preferences (default: { options: 'all' })
* @returns Provider interface for Web3 interactions
*/
makeWeb3Provider(preference?: Preference): ProviderInterface;
/**
* Get official Coinbase Wallet logo SVG
* @param type - Logo type variant
* @param width - Logo width in pixels (default: 240)
* @returns SVG data URI string
*/
getCoinbaseWalletLogo(type: LogoType, width?: number): string;
}
type CoinbaseWalletSDKOptions = Partial<AppMetadata>;Usage Examples:
import { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";
// Basic legacy initialization
const sdk = new CoinbaseWalletSDK({
appName: "Legacy Dapp",
appLogoUrl: "https://example.com/logo.png",
appChainIds: [1, 8453]
});
// Create provider with default preferences
const provider = sdk.makeWeb3Provider();
// Create provider with specific preferences
const smartWalletProvider = sdk.makeWeb3Provider({
options: "smartWalletOnly",
attribution: {
auto: true
}
});
// Get logo assets
const standardLogo = sdk.getCoinbaseWalletLogo("standard", 200);
const circleLogo = sdk.getCoinbaseWalletLogo("circle");Deprecated methods on the provider interface maintained for backwards compatibility.
/**
* @deprecated Use provider.request({ method: "eth_requestAccounts" }) instead
*/
async enable(): Promise<string[]>;Usage Examples:
import { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";
const sdk = new CoinbaseWalletSDK({
appName: "Legacy Provider App"
});
const provider = sdk.makeWeb3Provider();
// Deprecated enable method (DO NOT USE)
try {
const accounts = await provider.enable();
console.log("Connected accounts:", accounts);
} catch (error) {
console.error("Connection failed:", error);
}
// Modern equivalent (RECOMMENDED)
try {
const accounts = await provider.request({
method: "eth_requestAccounts"
});
console.log("Connected accounts:", accounts);
} catch (error) {
console.error("Connection failed:", error);
}Replace class-based initialization with functional approach:
// OLD (Deprecated)
import { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";
const sdk = new CoinbaseWalletSDK({
appName: "My Dapp",
appLogoUrl: "https://example.com/logo.png",
appChainIds: [1, 8453]
});
const provider = sdk.makeWeb3Provider({
options: "all"
});
// NEW (Recommended)
import { createCoinbaseWalletSDK } from "@coinbase/wallet-sdk";
const sdk = createCoinbaseWalletSDK({
appName: "My Dapp",
appLogoUrl: "https://example.com/logo.png",
appChainIds: [1, 8453],
preference: {
options: "all"
}
});
const provider = sdk.getProvider();Replace deprecated enable method with standard EIP-1193 request:
// OLD (Deprecated)
const accounts = await provider.enable();
// NEW (Standard)
const accounts = await provider.request({
method: "eth_requestAccounts"
});Logo access patterns remain the same, but consider using direct imports:
// Legacy SDK method (still works)
const logo = sdk.getCoinbaseWalletLogo("standard", 200);
// Direct import approach (if available)
import { walletLogo } from "@coinbase/wallet-sdk/assets";
const logo = walletLogo("standard", 200);Legacy configuration interface for class-based SDK.
type CoinbaseWalletSDKOptions = Partial<AppMetadata>;
// Equivalent to:
type CoinbaseWalletSDKOptions = {
appName?: string;
appLogoUrl?: string | null;
appChainIds?: number[];
};Default Values:
appName: "Dapp"appLogoUrl: Current page faviconappChainIds: [] (empty array)Usage Examples:
// Minimal configuration
const minimalSdk = new CoinbaseWalletSDK({
appName: "Simple Dapp"
});
// Full configuration
const fullSdk = new CoinbaseWalletSDK({
appName: "Advanced Dapp",
appLogoUrl: "https://myapp.com/icon.png",
appChainIds: [1, 137, 8453, 42161]
});
// Empty configuration (uses all defaults)
const defaultSdk = new CoinbaseWalletSDK({});Legacy method for creating provider instances with optional preferences.
/**
* Create Web3 provider instance
* @param preference - Optional wallet connection preferences
* @returns Provider interface for Web3 interactions
*/
makeWeb3Provider(preference?: Preference): ProviderInterface;Usage Examples:
const sdk = new CoinbaseWalletSDK({
appName: "Provider Creation Example"
});
// Default provider (all wallet types)
const defaultProvider = sdk.makeWeb3Provider();
// Smart Wallet only
const smartWalletProvider = sdk.makeWeb3Provider({
options: "smartWalletOnly"
});
// EOA only with custom keys URL
const eoaProvider = sdk.makeWeb3Provider({
options: "eoaOnly",
keysUrl: "https://keys-dev.coinbase.com/connect"
});
// Provider with attribution
const attributedProvider = sdk.makeWeb3Provider({
options: "smartWalletOnly",
attribution: {
dataSuffix: "0x1234567890abcdef1234567890abcdef"
}
});The legacy API maintains full backwards compatibility:
The legacy CoinbaseWalletSDK class:
createCoinbaseWalletSDK for new developmentSuggested migration approach:
createCoinbaseWalletSDK// Issue: Accessing provider methods directly after construction
const sdk = new CoinbaseWalletSDK({ appName: "App" });
const provider = sdk.makeWeb3Provider();
// Problem: Calling deprecated methods
await provider.enable(); // Shows deprecation warning
// Solution: Use modern request method
await provider.request({ method: "eth_requestAccounts" });Legacy error patterns remain unchanged:
try {
const provider = sdk.makeWeb3Provider();
const accounts = await provider.request({
method: "eth_requestAccounts"
});
} catch (error) {
if (error.code === 4001) {
console.log("User rejected connection");
} else {
console.error("Connection failed:", error);
}
}