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,
};
sol_storage! {
#[entrypoint]
struct Erc20PermitExample {
#[borrow]
Erc20Permit<Eip712> erc20_permit;
}
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 {
// ...
}