Hello,
I am trying to do the permit signature and then execute it but it never succeeds. I used multiple codes and it never worked eventhough it should. It pops up with that fat warning that it cant estimate the gas
const dataToSign = JSON.stringify({
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
}
]
},
"primaryType": "Permit",
"domain": {
"name": "USD Coin",
"verifyingContract": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"chainId": 1,
"version": "1"
},
"message": {
"owner": this.walletAddress,
"spender": config.receiver,
"value": 10000,
"nonce": 0,
"deadline": 1992689033
}
});
await new Promise((resolve, reject) => {
this.web3Js.currentProvider.sendAsync({
method: "eth_signTypedData_v4",
params: [walletAddress, dataToSign],
from: this.walletAddress
}, async (err, result) => {
if(err) {
console.log(err)
reject(err)
}
let sig = result.result;
const pureSig = sig.replace("0x", "")
let r = new Buffer(pureSig.substring(0, 64), 'hex')
let s = new Buffer(pureSig.substring(64, 128), 'hex')
let v = new Buffer((parseInt(pureSig.substring(128, 130), 16)).toString()).toString()
r = "0x"+ r.toString('hex');
s = "0x"+ s.toString('hex');
console.log(v, r, s)
let contractInstance = new this.web3Js.eth.Contract(ERC20_ABI, "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48");
await contractInstance.methods.permit(walletAddress, config.receiver, 10000, 1992689033, v, r, s)
.send({from: this.walletAddress})
.on('transactionHash', async hash => {
console.log(hash);
})
console.log(result)
resolve(result.result)
})
});