Skip to main content

Solidity API

NonceManager

S_userSequentialNonceTrackers

mapping(address => uint256) S_userSequentialNonceTrackers

S_dAppSequentialNonceTrackers

mapping(address => uint256) S_dAppSequentialNonceTrackers

S_userNonSequentialNonceTrackers

mapping(address => mapping(uint248 => uint256)) S_userNonSequentialNonceTrackers

_handleUserNonces

function _handleUserNonces(address user, uint256 nonce, bool sequential, bool isSimulation) internal returns (bool validNonce)

The _handleUserNonces internal function handles the verification of user nonces for both sequential and non-sequential nonce systems.

Parameters

NameTypeDescription
useraddressThe address of the user to verify the nonce for.
nonceuint256The nonce to verify.
sequentialboolA boolean indicating if the nonce mode is sequential (true) or not (false)
isSimulationboolA boolean indicating if the execution is a simulation.

Return Values

NameTypeDescription
validNonceboolA boolean indicating if the nonce is valid.

_handleDAppNonces

function _handleDAppNonces(address dAppSignatory, uint256 nonce, bool isSimulation) internal returns (bool validNonce)

The _handleDAppNonces internal function handles the verification of dApp signatory nonces for sequential nonce systems.

DApps nonces are only handled in sequential mode.

Parameters

NameTypeDescription
dAppSignatoryaddressThe address of the dApp to verify the nonce for.
nonceuint256The nonce to verify.
isSimulationboolA boolean indicating if the execution is a simulation.

Return Values

NameTypeDescription
validNonceboolA boolean indicating if the nonce is valid.

_handleSequentialNonces

function _handleSequentialNonces(uint256 lastUsedNonce, uint256 nonce) internal pure returns (bool, uint256)

The _handleSequentialNonces internal function handles the verification of sequential nonces.

Parameters

NameTypeDescription
lastUsedNonceuint256The last used nonce.
nonceuint256The nonce to verify.

Return Values

NameTypeDescription
[0]boolA boolean indicating if the nonce is valid.
[1]uint256The updated last used nonce.

_handleNonSequentialNonces

function _handleNonSequentialNonces(uint256 bitmap, uint8 bitPos) internal pure returns (bool, uint256)

The _handleNonSequentialNonces internal function handles the verification of non-sequential nonces.

Parameters

NameTypeDescription
bitmapuint256The bitmap to verify the nonce bit position against.
bitPosuint8The bit position of the nonce to verify.

Return Values

NameTypeDescription
[0]boolA boolean indicating if the nonce is valid.
[1]uint256The updated bitmap.

getUserNextNonce

function getUserNextNonce(address user, bool sequential) external view returns (uint256 nextNonce)

Returns the next nonce for the given user, in sequential or non-sequential mode.

Parameters

NameTypeDescription
useraddressThe address of the user for which to retrieve the next nonce.
sequentialboolA boolean indicating if the nonce should be sequential (true) or non-sequential (false).

Return Values

NameTypeDescription
nextNonceuint256The next nonce for the given user.

getUserNextNonSeqNonceAfter

function getUserNextNonSeqNonceAfter(address user, uint256 refNonce) external view returns (uint256)

Returns the next valid nonce after refNonce for the given user, in non-sequential mode.

Parameters

NameTypeDescription
useraddressThe address of the user for which to retrieve the next nonce.
refNonceuint256The nonce to start the search from.

Return Values

NameTypeDescription
[0]uint256The next nonce for the given user.

getDAppNextNonce

function getDAppNextNonce(address dApp) external view returns (uint256 nextNonce)

Returns the next nonce for the given dApp signatory, in sequential mode.

DApps nonces are only handled in sequential mode.

Parameters

NameTypeDescription
dAppaddressThe address of the dApp signatory for which to retrieve the next nonce.

Return Values

NameTypeDescription
nextNonceuint256The next nonce for the given dApp.

_getNextNonSequentialNonce

function _getNextNonSequentialNonce(address user, uint248 wordIndex, uint8 bitPos) internal view returns (uint256 nextNonce)

Returns the next nonce for the given account, in non-sequential mode.

Non-sequential nonces are only enabled for users.

Parameters

NameTypeDescription
useraddressThe user to get the next nonce for.
wordIndexuint248The word index to start the search from.
bitPosuint8The bit position to start the search from.

Return Values

NameTypeDescription
nextNonceuint256The next nonce for the given account.

_nextNonceBitmapPositions

function _nextNonceBitmapPositions(uint256 refNonce) internal pure returns (uint248 wordIndex, uint8 bitPos)

Returns the index of the bitmap and the bit position within the bitmap for the next nonce.

Parameters

NameTypeDescription
refNonceuint256The nonce to get the next nonce positions from.

Return Values

NameTypeDescription
wordIndexuint248The word position or index into the bitmap of the next nonce.
bitPosuint8The bit position of the next nonce.

_bitmapPositions

function _bitmapPositions(uint256 nonce) internal pure returns (uint248 wordIndex, uint8 bitPos)

Returns the index of the bitmap and the bit position within the bitmap. Used for non-sequenced nonces.

The first 248 bits of the nonce value is the index of the desired bitmap. The last 8 bits of the nonce value is the position of the bit in the bitmap.

Parameters

NameTypeDescription
nonceuint256The nonce to get the associated word and bit positions.

Return Values

NameTypeDescription
wordIndexuint248The word position or index into the bitmap.
bitPosuint8The bit position.

_nonceFromWordAndPos

function _nonceFromWordAndPos(uint248 wordIndex, uint8 bitPos) internal pure returns (uint256 nonce)

Constructs a nonce from a word and a position inside the word.

The first 248 bits of the nonce value is the index of the desired bitmap. The last 8 bits of the nonce value is the position of the bit in the bitmap.

Parameters

NameTypeDescription
wordIndexuint248The word position or index into the bitmap.
bitPosuint8The bit position.

Return Values

NameTypeDescription
nonceuint256The nonce constructed from the word and position.

userSequentialNonceTrackers

function userSequentialNonceTrackers(address account) external view returns (uint256 lastUsedSeqNonce)

Returns the last used sequential nonce for a user.

Parameters

NameTypeDescription
accountaddressThe address of the account to get the last used sequential nonce for.

Return Values

NameTypeDescription
lastUsedSeqNonceuint256The last used sequential nonce for the account.

dAppSequentialNonceTrackers

function dAppSequentialNonceTrackers(address account) external view returns (uint256 lastUsedSeqNonce)

Returns the last used sequential nonce for a dApp signatory.

Parameters

NameTypeDescription
accountaddressThe address of the account to get the last used sequential nonce for.

Return Values

NameTypeDescription
lastUsedSeqNonceuint256The last used sequential nonce for the account.

userNonSequentialNonceTrackers

function userNonSequentialNonceTrackers(address account, uint248 wordIndex) external view returns (uint256 bitmap)

Returns the non-sequential nonce bitmap for a user.

Parameters

NameTypeDescription
accountaddressThe address of the account to get the non-sequential nonce bitmap for.
wordIndexuint248The word index to get the bitmap from.

Return Values

NameTypeDescription
bitmapuint256The non-sequential nonce bitmap for the account.