Withdraw Offer Signature Structure
To authorize the withdrawOffer
operation within the MNS service, the user (the original offeror) must generate a cryptographic signature compliant with the EIP-191 standard.
This signature proves the offeror's intent and authorization to withdraw a specific, previously placed offer from a target username.
Signed Message Format
The message is constructed by concatenating the following components as strings, separated by commas (,
):
string.concat(
"5761d8ed",
",",
_username,
",",
Strings.toString(_offerId),
",",
Strings.toString(_nameServiceNonce)
)
1. MNS Withdraw Offer Identifier (Hex String):
- Value:
5761d8ed
- Purpose: A specific identifier used within the EIP-191 framework to distinguish MNS
withdrawOffer
messages from other types of signed messages.
2. Target Username (String):
- Value: The
_username
string itself. - Purpose: Specifies the username associated with the offer that is being withdrawn.
3. Offer ID (String):
- Value: The result of
Strings.toString(_offerId)
. - Purpose: The string representation of the unique identifier (
uint256
) assigned to the specific offer when it was created viamakeOffer
. This identifies which offer to withdraw.
4. MNS Nonce (String):
- Value: The result of
Strings.toString(_nameServiceNonce)
. - Purpose: The string representation of the user's (original offeror's) nonce specific to the MNS contract for this
withdrawOffer
action. This prevents replay attacks.
Practical Example
Let's say we want to withdraw an offer with the following parameters:
- Target Username:
"alice"
- Offer ID:
42
(the unique identifier of the offer to withdraw) - Name Service Nonce:
7
The message would be constructed as:
"5761d8ed,alice,42,7"
Message Breakdown:
5761d8ed
: Function selector for withdraw offer verificationalice
: The username associated with the offer being withdrawn42
: The unique ID of the specific offer to withdraw7
: The offeror's name service nonce
This message would then be signed using EIP-191 standard, and the resulting signature would be used to verify the withdrawal request in the verifyMessageSignedForWithdrawOffer
function.
- The function selector
5761d8ed
is the first 4 bytes of the keccak256 hash of the function signature forverifyMessageSignedForWithdrawOffer
Strings.toString
converts a number to a string (standard OpenZeppelin utility)- The signature verification uses the EIP-191 standard for message signing
- The
_offerId
must correspond to an existing offer that was previously made by the same user - Only the original offeror can withdraw their own offers