我正在尝试将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条答案
按热度按时间tjjdgumg1#
你分享的Web3Modal是针对React web应用而不是React Native应用的。你应该看看Web3Modal WalletConnect integration,它使用Wagmi库来实现React Native。