Code to reproduce
Hello!
I've created test contract with just erc20 and permit:
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
contract MyToken is ERC20, ERC20Permit {
constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {
_mint(msg.sender, 10000 * 10 ** decimals());
}
}
And deployed it to Arbitrum Sepolia network:
Next It try to call permit method:
// Define Signature
const domain = {
name: name,
version: '1',
chainId: "421614",
verifyingContract: GRN_TOKEN,
};
// Define types
const types = {
Permit: [
{ name: 'owner', type: 'address' },
{ name: 'spender', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'deadline', type: 'uint256' },
{ name: 'value', type: 'uint256' },
],
};
// Define transaction
const values = {
owner: tokenOwner.address,
spender: tokenReceiver.address,
nonce: nonce,
deadline: deadline,
value: value,
};
// Sign data
const signature = await tokenOwner._signTypedData(domain, types, values);
const r = signature.substring(0, 66);
const s = '0x' + signature.substring(66, 130);
const v = parseInt(signature.substring(130, 132), 16);
// Split signature
const sig = ethers.utils.splitSignature(signature);
return await Token.connect(tokenReceiver).permit(
tokenOwner.address,
tokenReceiver.address,
value,
deadline,
v,
r,
s,
{
gasPrice: gas,
gasLimit: 5000000,
},
);
But I get error always:
Warning! Error encountered during contract execution [execution reverted ]
What could be the problem and how to debug it? I already have checked all the internet and nothing helps(((