NoncesLib
Title: NoncesLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Nonces.sol)
Library for tracking per-account nonces used in replay-protection schemes.
Functions
noncesStorage
function noncesStorage() internal pure returns (NoncesStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | NoncesStorage |
__Nonces_init
Initializes the Nonces module.
Must be called inside a pre/postInitializer block. Registers the INonces interface for ERC-165 discovery.
function __Nonces_init() internal;registerInterface
Registers support for the INonces interface via ERC-165.
function registerInterface() internal;nonces
Returns the current nonce for the given owner.
function nonces(address owner) internal view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address to query. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The current nonce. |
useNonce
Returns the current nonce for the caller and increments it.
Does not check the nonce value; use useCheckedNonce for validated increments.
function useNonce(address owner) internal returns (uint256 current);Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The address whose nonce to consume. |
Returns
| Name | Type | Description |
|---|---|---|
| current | uint256 | The nonce value before incrementing. |
useCheckedNonce
Consumes a nonce after verifying it matches the expected value.
Reverts with InvalidAccountNonce if nonce does not equal the current nonce.
function useCheckedNonce(address owner, uint256 nonce) internal;Parameters
| Name | Type | Description |
|---|---|---|
| owner | address | The account whose nonce to consume. |
| nonce | uint256 | The expected current nonce value. |