1

I am using the exactly same wallet on both Wallet Connect (Chrome) + MetaMask (mobile) and MetaMask (Chrome) in calling a mint function of my smart contract. With MetaMask (Chrome), the process goes smoothly; but with Wallet Connect (Chrome) + MetaMask (mobile), this error occurs:

inpage.js:1 MetaMask - RPC Error: The requested account and/or method has not been authorized by the user.

I am simply use

const contract = new web3.eth.Contract(
  abi,
  contractAddress
);

contract.methods.mintBatch(something).send({from: walletId, value: value}, (err, res) => callback(err, res));

with both Wallet Connect (Chrome) + MetaMask (mobile) and MetaMask (Chrome). Does it require additional set-up for Wallet Connect?

1 Answer 1

1

Turns out I need to use the following to replace the usual web3 to make it work:

const provider = new WalletConnectProvider({
  infuraId: process.env.INFURA_PROJECT_ID, // Required
});

walletConnectWeb3 = new Web3(provider as any);

contractSubstitute = new walletConnectWeb3.eth.Contract(abi, contractAddress);

contractSubstitute.methods.mintBatch(something).send({from: walletId, value: value}, (err, res) => callback(err, res));

The web3 has to be walletConnect web3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.