我正在尝试将coinbase钱包集成到我的react native dapp中。
我指的是this
这里是代码。
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({})
我得到下面的错误:
1条答案
按热度按时间vatpfxk51#
您分享的Web3Modal针对的是React Web应用,而不是React Native应用。你应该看看Web3Modal WalletConnect integration,它使用Wagmi库进行React Native。