This page explains how to integrate Coinbase Wallet SDK as the default provider for your app using web3.js. You can follow a similar pattern if you are using ethers.js.
In your App.tsx file, add the following code to initialize Coinbase Wallet SDK and a Web3 object:
Copy
Ask AI
// TypeScriptimport CoinbaseWalletSDK from "@coinbase/wallet-sdk";import Web3 from "web3";const APP_NAME = "My Awesome App";const APP_LOGO_URL = "https://example.com/logo.png";const APP_SUPPORTED_CHAIN_IDS = [8453, 84532];// Initialize Coinbase Wallet SDKexport const coinbaseWallet = new CoinbaseWalletSDK({ appName: APP_NAME, appLogoUrl: APP_LOGO_URL, chainIds: APP_SUPPORTED_CHAIN_IDS,});// Initialize a Web3 Provider objectexport const ethereum = coinbaseWallet.makeWeb3Provider();// Initialize a Web3 objectexport const web3 = new Web3(ethereum as any);
Coinbase Wallet SDK uses an rpcUrl provided by Coinbase Wallet clients regardless of the rpcUrl passed into makeWeb3Provider for whitelisted networks. Wallet SDK needs an rpcUrl to be provided by the app as a fallback.