pub struct Permit {
pub owner: [u8; 20],
pub spender: [u8; 20],
pub value: [u8; 32],
pub nonce: u64,
pub deadline: u64,
}Expand description
EIP-2612 Permit message for gasless ERC-20 token approvals.
This constructs the EIP-712 typed data that the token holder signs,
allowing a third party to call permit() on the ERC-20 contract.
Fields§
§owner: [u8; 20]Token holder granting approval.
spender: [u8; 20]Address being approved to spend tokens.
value: [u8; 32]Amount of tokens to approve (as 32-byte big-endian uint256).
nonce: u64Current nonce of the owner on the token contract.
deadline: u64Unix timestamp deadline for the permit signature.
Implementations§
Source§impl Permit
impl Permit
Sourcepub fn type_hash() -> [u8; 32]
pub fn type_hash() -> [u8; 32]
Compute the EIP-712 PERMIT_TYPEHASH.
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
Sourcepub fn struct_hash(&self) -> [u8; 32]
pub fn struct_hash(&self) -> [u8; 32]
Compute the struct hash for this permit.
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonce, deadline))
Sourcepub fn signing_hash(&self, domain_separator: &[u8; 32]) -> [u8; 32]
pub fn signing_hash(&self, domain_separator: &[u8; 32]) -> [u8; 32]
Compute the EIP-712 signing hash for this permit.
keccak256("\x19\x01" || domain_separator || struct_hash)
Sourcepub fn sign(
&self,
signer: &EthereumSigner,
domain_separator: &[u8; 32],
) -> Result<EthereumSignature, SignerError>
pub fn sign( &self, signer: &EthereumSigner, domain_separator: &[u8; 32], ) -> Result<EthereumSignature, SignerError>
Sign this permit with the given signer.