I have a web app using Wallet to send ERC20 transactions (contract interactions -> transfer). I am using Metamask (mainnet) to interact with the web app. For the login (connect) I get the confirm dialog in Metamask, so do I for the first transaction. However, from the second transaction on, I don't get the confirm dialog. Does anyone know what the problem could be?
I have a web app using Wallet to send ERC20 transactions (contract interactions -> transfer). I am using Metamask (mainnet) to interact with the web app. For the login (connect) I get the confirm dialog in Metamask, so do I for the first transaction. However, from the second transaction on, I don't get the confirm dialog. Does anyone know what the problem could be?
// SESSION INIT
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
infuraId: INFURA_ID,
}
},
};
web3Modal = new Web3Modal({
cacheProvider: true, // optional
providerOptions, // required
disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
});
console.log("Web3Modal instance is", web3Modal);
try {
provider = await web3Modal.connect();
} catch(e) {
console.log("Could not get a wallet connection", e);
return;
}
//SEND TRANSACTION
async function transferMoney(toAccountId, amount, tokenContract) {
var data = tokenContract.methods.transferByAccountId(toAccountId, amount).encodeABI()
console.log(data)
var gasPrice = await web3.eth.getGasPrice()
const tx = {
from: selectedAccount,
to: tokenContract.options.address,
gas: TRANSFER_GAS_ESTIMATION,
gasPrice: gasPrice,
data: data,
};
try {
console.log(tx)
var txHash = await provider.connector.sendTransaction(tx)
console.log(txHash)
} catch (err) {
console.log(err.message);
}
}
// DISCONNECT SESSION
async function onDisconnect() {
console.log("Killing the wallet connection", provider);
if(provider.close) {
await provider.close();
await web3Modal.clearCachedProvider();
provider = null;
}
selectedAccount = null;
location.href = 'login.html'
}