Staking/Unstaking Signature Structure
To authorize staking operations like presaleStaking
or publicStaking
, or their corresponding unstaking actions, the user must generate a cryptographic signature compliant with the EIP-191 standard.
This signature proves the user's intent and authorization to perform a specific staking or unstaking action with a defined amount of sMATE tokens, according to the parameters provided in the signed message.
Signed Message Format
The message is constructed by concatenating the following components as strings, separated by commas (,
):
string.concat(
isPublicStaking ? "21cc1749" : "6257deec",
",",
_isStaking ? "true" : "false",
",",
Strings.toString(_amountOfSMate),
",",
Strings.toString(_nonce)
)
1. Staking Context Identifier (Hex String):
- Value: Depends on the context of the staking/unstaking action:
21cc1749
: Used for signatures intended for thepublicStaking
function.6257deec
: Used for signatures intended for thepresaleStaking
function.
2. Staking Action Flag (String):
- Value: The literal string
"true"
if the user intends to stake (corresponding to the function's_isStaking
parameter being true), or"false"
if the user intends to unstake (_isStaking
being false). - Purpose: Clearly indicates whether the authorized operation is for staking sMATE tokens into the contract or unstaking them from the contract.
3. sMATE Amount (String):
- Value: The result of
Strings.toString(_amountOfSMate)
. - Purpose: The string representation of the quantity (
uint256
) of sMATE tokens the user wishes to stake or unstake in this specific operation.
4. Nonce (String):
- Value: The result of
Strings.toString(_nonce)
. - Purpose: The string representation of the user's nonce specific to the relevant staking contract (Presale or Public) for this type of action. This prevents replay attacks for staking/unstaking operations initiated by the user.
tip
addressToString
converts an address to a lowercase stringStrings.toString
converts a number to a stringAdvancedStrings.bytes32ToString(bytes32 _input)
converts abytes32
value into its lowercase hexadecimal string representation