ERC-20 Permit

Adds the permit method, which can be used to change an account’s ERC20 allowance (see IErc20::allowance) by presenting a message signed by the account. By not relying on IErc20::approve, the token holder account doesn’t need to send a transaction, and thus is not required to hold Ether at all.

Usage

In order to have ERC-20 Permit token, you need to use only this contract without ERC-20 as follows:

use openzeppelin_stylus::{
    token::erc20::extensions::Erc20Permit, utils::cryptography::eip712::IEip712,
};

#[entrypoint]
#[storage]
struct Erc20PermitExample {
    #[borrow]
    pub erc20_permit: Erc20Permit<Eip712>,
}

#[storage]
struct Eip712 {}

// Define `NAME` and `VERSION` for your contract.
impl IEip712 for Eip712 {
    const NAME: &'static str = "ERC-20 Permit Example";
    const VERSION: &'static str = "1";
}

#[public]
#[inherit(Erc20Permit<Eip712>)]
impl Erc20PermitExample {
    // ...
}