ERC2612 allows for gasless approvals for ERC20 via signatures. While many ERC20 tokens now incorporate permits, many do not. contract which serves as a wrapper to an ERC20 and allows permits.
Created a singleton contract which implements permit and relies on max allowance.
After the user gives max allowance to address(this) user can send a signature with permit method which checks the signature and transfers the tokens using safeTransferFrom method from SafeERC20.
Deployed and verified Permit contract address on kovan link
0xbe05377f035e00B3052633c9c813a2D1F20928E7-
Clone the repository
git clone https://github.com/jatinj615/permit.git cd permit -
create
.envfile and set environment variablestouch .env // structure of env file ALCHEMY_API_KEY=<YOUR_ALCHEMY_KEY> // can use - GuY3V68erOgOioj6jYTGb1IfkJCIxhLH MNEMONIC=<YOUR_MNEMONIC_PRIVATE_KEY> OWNER_PRIVATE_KEY=<YOUR_OWNER_PRIVATE_KEY>
refer to
.env.examplefile for refrence.To get
OWNER_PRIVATE_KEYrunnpx hardhat node // Ouput Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH) Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 //OWNER_PRIVATE_KEY(must be of Account #0)
-
Install the dependencies
npm install
-
Compile the code
npx hardhat compile
npx hardhat testnpx hardhat run scripts/deployer.ts --network <network_name>