How to Connect to Coinbase wallet extension with coinbase wallet SDK?

Viewed 537

I am trying to connect my coinbase wallet extension from my react app. I have followed the official docs that guide how to do it using the @coinbase/wallet-sdk, but I cannot connect to the wallet nor I am able to open the extension's popup in chrome.
Here is the function that I am using,


const connectToCoinBase = async () => {
    const APP_NAME = "Lottery";
    const APP_LOGO_URL = "";
    const DEFAULT_ETH_JSONRPC_URL =
      "https://rinkeby.infura.io/v3/my-api-key";
    const DEFAULT_CHAIN_ID = 4;

    const coinbaseWallet = new CoinbaseWalletSDK({
      appName: APP_NAME,
      appLogoUrl: APP_LOGO_URL,
      darkMode: false,
    });
    

    const ethereum = coinbaseWallet.makeWeb3Provider(
      DEFAULT_ETH_JSONRPC_URL,
      DEFAULT_CHAIN_ID
    );
  ]

    const account = ethereum.request({ method: "eth_requestAccounts" }); //gives undefined
   
    const web3 = new Web3(ethereum);
  };


How to popup for the extension will open? How to get the address from the wallet after the connection is accepted?

0 Answers
Related