bcnmy / mexa-sdk

Repository contains mexa sdk code that can be plugged into your dapp and can leverage meta transaction feature.
MIT License
106 stars 41 forks source link

Not able to sign the transaction when integrating Gasless transaction using web3Auth wallet. #139

Open sudeepkotari opened 2 years ago

sudeepkotari commented 2 years ago

Description I have created an NFT minting web app, User can authenticate using either Metamask or google login using web3auth. Used Biconomy for the gasless transactions when the user mint an NFT. When I connect my web app using Metamask I can pass my transaction through Biconomy and it will ask to sign the transaction and successful mints an NFT. But if I connect my web app with google login using web3auth I can able to read and write a smart contract with paying gas commonly it works fine but if I try to call the transaction using Biconomy I am getting the "The requested account and/or method has not been authorized by the user." error, and not able to sign the transaction.

To Reproduce import { Biconomy } from "@biconomy/mexa"; import Web3 from "web3";

const [contract, setContract] = useState({}); const [biconomyProvider, setBiconomyProvider] = useState({});

const networkProvider = new Web3.providers.HttpProvider(RPCURL); const biconomyApiKey =

const web3 = new Web3(Web3.givenProvider); const biconomy = new Biconomy(networkProvider, { walletProvider: web3.currentProvider, apiKey: biconomyApiKey, debug: true, });

setBiconomyProvider(biconomy); web3.setProvider(biconomy);

biconomy .onEvent(biconomy.READY, () => { const ABI: any[] = MINTNFT.abi; const contractInst = new web3.eth.Contract(ABI, ContractAddress); setContract(contractInst); }) .onEvent(biconomy.ERROR, (ex: any) => { console.log("biconomy error", ex); }); Once Biconomy is initialized I tried calling the mint function

const tokenURI = "https://example.com/1.json"; let tx = contract.methods.mintNFT(tokenURI).send({ from: walletAddress.toString(), to: "0xCCd18xxxxxxxxxxxxxb446b97C3", // Contract address signatureType: biconomyProvider["EIP712_SIGN"], });

tx.on("transactionHash", function () {}) .once("confirmation", function (transactionHash: any) { console.log("transactionHash", transactionHash); }) .on("error", function (ex: any) { console.log("exception", ex); }); And it returns

{code: 4100, message: 'The requested account and/or method has not been authorized by the user.'}

Expected behavior Same if I try with Metamask wallet connection, It triggers the popup to sign the transaction and generated the hash

Screenshot

Screenshot from 2022-07-29 11-49-59

Device Info (please complete the following information): Device: MacBook Pro, Apple M1 OS: Big Sur Browser: Brave Web3Auth Version: 1.0.0 Biconomy Version: 2.0.32 Web3 Version: 1.7.3