LSP25MultiChannelNonce
Implementation of the multi channel nonce and the signature verification defined in the LSP25 standard.
This contract can be used as a backbone for other smart contracts to implement meta-transactions via the LSP25 Execute Relay Call interface. It contains a storage of nonces for signer addresses across various channel IDs, enabling these signers to submit signed transactions that order-independant. (transactions that do not need to be submitted one after the other in a specific order). Finally, it contains internal functions to verify signatures for specific calldata according the signature format specified in the LSP25 standard.
Internal Methods​
Any method labeled as internal
serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.
Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.
_getNonce​
function _getNonce(
address from,
uint128 channelId
) internal view returns (uint256 idx);
Read the nonce for a from
address on a specific channelId
.
This will return an idx
, which is the concatenation of two uint128
as follow:
-
the
channelId
where the nonce was queried for. -
the actual nonce of the given
channelId
. For example, if onchannelId
number5
, the latest nonce is1
, theidx
returned by this function will be:
// in decimals = 1701411834604692317316873037158841057281
idx = 0x0000000000000000000000000000000500000000000000000000000000000001
This idx can be described as follow:
channelId => 5 nonce in this channel => 1
v------------------------------v-------------------------------v
0x0000000000000000000000000000000500000000000000000000000000000001
Parameters​
Name | Type | Description |
---|---|---|
from | address | The address to read the nonce for. |
channelId | uint128 | The channel in which to extract the nonce. |
Returns​
Name | Type | Description |
---|---|---|
idx | uint256 | The idx composed of two uint128 : the channelId + nonce in channel concatenated together in a single uint256 value. |