1
import { WalletConnectConnector } from "@web3-react/walletconnect-connector";

I have used this for connecting walletconnect through QR code and used useWeb3React for connecting to wallet.
Metamask extension is working fine but not able to use walletconnect for transactions.

const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY;
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
var web3 = createAlchemyWeb3(alchemyKey);

const transactionParameters = [
  {
    method: "eth_sendTransaction",
    params: [
      {
        to: contractAddress, // Required except during contract publications.
        from: acct, // must match user's active address.
        data: window.contract.methods.mintNFT(acct, tokenURI).encodeABI(), //make call to NFT smart contract
      },
    ],
  },
];

await web3.eth
  .sendTransaction(transactionParameters)
  .on("receipt", (receipt) => {
    console.log(receipt, "receipt");
  })
  .on("transactionHash", (hash) => {
    console.log(hash, "hash");
  })
  .on("error", (err) => {
    console.log(err, "error");
  });

The above works fine with metamask extension but not with Walletconnect.

possum
  • 1,837
  • 3
  • 9
  • 18

1 Answers1

0

I think the issue is with your web3 provider. Try to get web3 provider from useWeb3React itself.

eg:

const provider = connector.getProvider();
const web3 = new Web3(provider)
use this web3 to send transaction