Skip to content
Lattice

NoncesLib

Git Source

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

NameTypeDescription
$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

NameTypeDescription
owneraddressThe address to query.

Returns

NameTypeDescription
<none>uint256The 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

NameTypeDescription
owneraddressThe address whose nonce to consume.

Returns

NameTypeDescription
currentuint256The 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

NameTypeDescription
owneraddressThe account whose nonce to consume.
nonceuint256The expected current nonce value.