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.
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.
) internal view returns (uint256 idx);
Read the nonce for a
from address on a specific
This will return an
idx, which is the concatenation of two
uint128 as follow:
channelIdwhere the nonce was queried for.
the actual nonce of the given
channelId. For example, if on
5, the latest nonce is
idxreturned by this function will be:
// in decimals = 1701411834604692317316873037158841057281
idx = 0x0000000000000000000000000000000500000000000000000000000000000001
This idx can be described as follow:
channelId => 5 nonce in this channel => 1
|The address to read the nonce for.|
|The channel in which to extract the nonce.|
|The idx composed of two |
) internal view returns (address);
Recover the address of the signer that generated a
signature using the parameters provided
The address of the signer will be recovered using the LSP25 signature format.
|A 65 bytes long signature generated according to the signature format specified in the LSP25 standard.|
|The nonce that the signer used to generate the |
|The validity timestamp that the signer used to generate the signature (See |
|The amount of native tokens intended to be sent for the relay transaction.|
|The calldata to execute as a relay transaction that the signer signed for.|
|The address that signed, recovered from the |
function _verifyValidityTimestamps(uint256 validityTimestamps) internal view;
Verify that the current timestamp is within the date and time range provided by
function _isValidNonce(address from, uint256 idx) internal view returns (bool);
Verify that the nonce
_from (obtained via
getNonce) is valid in its channel ID.
The "idx" is a 256bits (unsigned) integer, where:
the 128 leftmost bits = channelId
and the 128 rightmost bits = nonce within the channel
|The signer's address.|
|The concatenation of the |
|true if the nonce is the latest nonce for the |