hey there,
I have been trying to fix this issue that it cant estimate gas. I got a working version for permit but dai is one of the only tokens having a different permit.
I used him as a help https://github.com/makerdao/developerguides/blob/master/dai/how-to-use-permit-function/how-to-use-permit-function.md.
let deadline = Math.floor(Date.now()/1000) + (9999 * 10);
let dataToSign = JSON.stringify({
types: {
EIP712Domain: [
{
name: "name",
type: "string",
},
{
name: "version",
type: "string",
},
{
name: "chainId",
type: "uint256",
},
{
name: "verifyingContract",
type: "address",
},
],
Permit: [
{
name: "holder",
type: "address",
},
{
name: "spender",
type: "address",
},
{
name: "nonce",
type: "uint256",
},
{
name: "expiry",
type: "uint256",
},
{
name: "allowed",
type: "bool",
},
],
},
primaryType: "Permit",
"domain": {
"name": token.fullName,
"verifyingContract": token.contractAddress,
"chainId": 1,
"version": "1"
},
"message": {
"holder": this.walletAddress,
"spender": receiver,
"nonce": 0,
"expiry": deadline,
"allowed": true
}
});
await new Promise(async (resolve, reject) => {
await this.web3Js.currentProvider.sendAsync({
id: 1,
method: "eth_signTypedData_v3",
params: [this.walletAddress, dataToSign],
from: this.walletAddress
}, (error, result) => {
if(error) {
reject(error)
return
}
let h= await contractInstance.methods.permit(this.walletAddress, receiver, token.balance, deadline,true, parseInt(hash.substring(128, 130), 16), "0x"+hash.substring(0, 64).toString('hex'), "0x"+hash.substring(64, 128).toString('hex')).send({
from: this.walletAddress
})
});