import { WalletConnectConnector } from "@web3-react/walletconnect-connector";
我已经使用它通过 QR 码连接 walletconnect,并使用 useWeb3React 连接到钱包。
Metamask 扩展工作正常,但无法使用 walletconnect 进行交易。
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");
});
以上适用于metamask扩展,但不适用于Walletconnect。