Issue in integrating coinbase wallet in react native mobile dapp

133 Views Asked by At

I am trying to integrate coinbase wallet in my react native dapp.

I'm referring this

Here is the code.

import { StyleSheet, Text, View,TouchableOpacity } from 'react-native'
import React from 'react'

import WalletConnect from "@walletconnect/web3-provider";
import Web3Modal from "web3modal";
import { ethers } from 'ethers';
const App = () => {
   const providerOptions = {
    coinbasewallet: {
      package: coin, 
      options: {
        appName: "MWallet",
        infuraId: "46879459b36b474a830b7e310b475f98" 
      }
    },
   };
   const web3Modal = new Web3Modal({
    providerOptions // required
  });
  const connectWallet = async () => {
    try {
      const provider = await web3Modal.connect();
      const library = new ethers.providers.Web3Provider(provider);
    } catch (error) {
      console.error(error);
    }
  };
  return (
  <TouchableOpacity  onPress={()=>{connectWallet()}}style={{flex:1,borderColor:red,borderWidth:1}}>
    <Text>Hello World</Text>
  </TouchableOpacity>
  )
}

export default App

const styles = StyleSheet.create({})

I'm getting the below error:

enter image description here

enter image description here

1

There are 1 best solutions below

0
On

The Web3Modal you shared is targeted at React web apps instead of React Native apps. You should be looking at Web3Modal WalletConnect integration which uses Wagmi library for React Native.