Appearance
Solidity API
ERC20Permit
derived from https://github.com/soliditylabs/ERC20-Permit (MIT license)
DOMAIN_SEPARATOR
solidity
function DOMAIN_SEPARATOR() external view returns (bytes32 domainSeparator)Returns the EIP-712 domain separator unique to the contract and chain
The domain separator is used as part of the permit signature verification process. It includes contract-specific information (name, version) and chain-specific data (chainId, contract address) to prevent signature replay attacks across different contracts or chains.
Return Values
| Name | Type | Description |
|---|---|---|
| domainSeparator | bytes32 | The 32-byte domain separator value |
nonces
solidity
function nonces(address owner) public view returns (uint256)Returns the current nonce for a given address
The nonce is incremented each time a permit is used, preventing signature replay attacks. Each owner's nonce starts at 0 and increases monotonically with each permit operation.
Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address whose nonce is being queried |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | uint256 | The current nonce value for the specified address |
permit
solidity
function permit(address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtualApproves spender to transfer tokens held by owner via signature
_Implements the EIP-2612 permit function. The signature is created using EIP-712 structured data signing. The deadline parameter helps prevent old signatures from being replayed.
The function validates:
- The deadline hasn't passed
- The signature is valid and from the token owner
- The nonce matches the owner's current nonce
After validation, it:
- Increments the owner's nonce
- Sets the approval amount for the spender_
Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address that owns the tokens and signed the permit |
| spender | address | The address that will be approved to spend the tokens |
| amount | uint256 | The number of tokens that can be spent |
| deadline | uint256 | The timestamp after which the permit is no longer valid |
| v | uint8 | The recovery byte of the signature (ECDSA parameter) |
| r | bytes32 | The first 32 bytes of the signature (ECDSA parameter) |
| s | bytes32 | The second 32 bytes of the signature (ECDSA parameter) |