demo-apps icon indicating copy to clipboard operation
demo-apps copied to clipboard

How to get Web3 object from Morails?

Open ksbek opened this issue 2 years ago • 0 comments

Hi @ErnoW,

I'm a react native developer. But I have no experience with connecting metamask and call smart contract functions yet. I found your code online. It's great to start. But I have some errors. Would be grateful if you can look at this problem and guide me. https://github.com/MoralisWeb3/demo-apps/tree/main/react-native-boilerplate

I want to get web3 object and run smart contract functions using the following code. const web3 = await Moralis.Web3.enableWeb3(); const tokenContract = new web3.eth.Contract(contractAbi, contractAddress)

But I got the following error. Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is not an object (evaluating '_ref.connector') enableViaWalletConnect$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:358153:29

I think there's an issue with enableViaWalletConnect function. https://github.com/MoralisWeb3/demo-apps/blob/main/react-native-boilerplate/frontend/Moralis/enableViaWalletConnect.ts#L9 There's no connector option in the response of the connect function. I think it's like an NPM version issue.

Thanks.

ksbek avatar Feb 03 '22 18:02 ksbek