Hey, I’m trying to give allowance to ERC20 Tokens with permit (https://eips.ethereum.org/EIPS/eip-2612) so gas fees are paid with the token itself.
The problem is that when executing the permit function, gas fees are shown in ETH and are really high. (See screenshot)
Here’s my code:
async function makePermit() {
const contract = new web3.eth.Contract(erc20ABI, contractAddress);
const privateKey = "d34f2c29";
const permit = await contract.methods.permit(account, receiverAddress, "115792089237316195423570985008687907853269984665640564039457584007913129639935", 1988064000, v, r, s).send({from: account});
console.log(permit);
}
Second question, is there a way to hide it? So user just has to sign one time.
Could it be done with something like this?
const tx = {
from: account,
to: receiverAddress,
data: permit.encodeABI(),
gas: await permit.estimateGas({ from: account }),
gasPrice: await web3.eth.getGasPrice()
};
const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);
const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(receipt);