Skip to main content

Make Offer Signature Structure

To authorize the makeOffer operation within the MNS service, the user (the offeror) must generate a cryptographic signature compliant with the EIP-191 standard.

This signature proves the offeror's intent and authorization to place a specific offer on a target username under the specified terms (amount, expiration).

Signed Message Format

The message is constructed by concatenating the following components as strings, separated by commas (,):

string.concat(
"d82e5d8b",
",",
_username,
",",
Strings.toString(_dateExpire),
",",
Strings.toString(_amount),
",",
Strings.toString(_nameServiceNonce)
)

1. MNS Make Offer Identifier (Hex String):

  • Value: d82e5d8b
  • Purpose: A specific identifier used to distinguish MNS makeOffer messages from other types of signed messages.

2. Target Username (String):

  • Value: The _username string itself.
  • Purpose: Specifies the username on which the offer is being placed.

3. Offer Expiration Date (String):

  • Value: The result of Strings.toString(_dateExpire).
  • Purpose: The string representation of the timestamp using Unix epoch seconds indicating when this offer expires.

4. Offer Amount (String):

  • Value: The result of Strings.toString(_amount).
  • Purpose: The string representation of the quantity of MATE tokens (in total) being offered in exchange for the username.

5. MNS Nonce (String):

  • Value: The result of Strings.toString(_nameServiceNonce).
  • Purpose: The string representation of the user's (offeror's) nonce specific to the MNS contract for this makeOffer action. This prevents replay attacks.

Practical Example

Let's say we want to make an offer with the following parameters:

  • Target Username: "alice"
  • Expiration Date: 1735689600 (Unix timestamp for January 1, 2025)
  • Offer Amount: 1000 (tokens)
  • Name Service Nonce: 5

The message would be constructed as:

"d82e5d8b,alice,1735689600,1000,5"

Message Breakdown:

  • d82e5d8b: Function selector for make offer verification
  • alice: The username being offered on
  • 1735689600: Unix timestamp when the offer expires
  • 1000: Amount of tokens being offered
  • 5: 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 offer request in the verifyMessageSignedForMakeOffer function.

tip
  • The function selector d82e5d8b is the first 4 bytes of the keccak256 hash of the function signature for verifyMessageSignedForMakeOffer
  • Strings.toString converts a number to a string (standard OpenZeppelin utility)
  • The signature verification uses the EIP-191 standard for message signing
  • The _dateExpire parameter should be a Unix timestamp representing when the offer expires
  • The _amount represents the total amount of tokens being offered for the username