acceptOffer
Function Type: external
Function Signature: acceptOffer(address,string,uint256,address,uint256,uint256,uint256,bytes,bytes)
Function Selector: 0xae36fe72
Allows the current owner (user) of a username (username) to accept a specific, active offer (offerID) made by another user. Accepting the offer triggers the transfer of the agreed principal tokens from the offeror to the owner, and transfers the ownership of the username to the original offeror.
Parameters
| Parameter Name | Type | Description |
|---|---|---|
user | address | The address of the current owner of the username who is accepting the offer. |
username | string | The username associated with the offer being accepted. |
offerID | uint256 | The unique identifier of the specific offer being accepted. |
token | address | The address of the token to be used for payment. |
amount | uint256 | The total amount to be transferred for the offer. |
priorityFee | uint256 | The priority fee amount. |
nonce | uint256 | The nonce value for the signature. |
signature_EVVM | bytes | The EVVM payment signature. |
signature | bytes | The NameService accept offer signature. |
Signature Links & EVVM Payment
- The EVVM payment signature (
signature_EVVM) covers the total amount and uses the Single Payment Signature Structure. - The NameService accept offer signature (
signature) must be generated by the current owner (user) and follows the Accept Offer Signature Structure. - The EVVM parameters facilitate the transfer of the offer funds and any optional priority fee from the offeror (
user).
Execution Methods
This function can be executed by any address.
Workflow
Failure at validation steps typically reverts the transaction.
- Username Owner Verification: Checks if the provided
_useraddress is the registered owner of the_username(e.g., using an internal ownership check likeonlyAdminOfIdentity). Reverts if_useris not the owner. - NameService Nonce Verification: Checks if the provided
_nonceis unused for the_userusing theverifyIfNonceIsAvailablemodifier. Reverts if the nonce is already used. - Offer validation: Retrieves the offer data associated with
_usernameand_offerID. Checks that the offer exists (e.g.,offerer != address(0)) and that itsexpireDatehas not passed based on the current block timestamp. Reverts if the offer is invalid or expired. - Signature Verification: Validates the
_signatureprovided by_user(the owner) against the reconstructed message hash usingverifyMessageSignedForAcceptOffer. Reverts if the signature is invalid according to the Accept Offer Signature Structure. - EVVM Payment Execution (Optional Priority Fee): If
_priorityFeeForFisheris greater than zero:- Calls an internal helper function (e.g.,
makePay) designed to interact with the EVVM'spayMateStakerfunction. - Uses the provided
_nonce_Evvm,_priority_Evvm, and_signature_Evvmparameters to authorize the EVVM payment. - This action attempts to transfer the
_priorityFeeForFisheramount of principal tokens from the_useraddress to themsg.senderaddress via the EVVM contract mechanism. - Reverts if this EVVM payment process fails.
- Calls an internal helper function (e.g.,
- Transaction Execution (Pay Seller): Calls an internal helper function (e.g.,
makeCaPay) to transfer the accepted offer funds (retrieved fromusernameOffers[_username][_offerID].amount). - Ownership Transfer: Transfers the ownership of the
_usernamewithin the NameService system from the current owner (_user) to the address of the original offeror (retrieved fromusernameOffers[_username][_offerID].offerer). - Offer Cleanup: Updates the
usernameOffers[_username][_offerID]entry by setting theoffererfield toaddress(0), marking the offer as fulfilled and the slot as empty/invalid. - Reward Distribution (to Executor): Calls an internal helper function (e.g.,
makeCaPay) to distribute rewards in principal tokens tomsg.sender(the executor). The rewards consist of:- A base MATE reward, typically fetched from the EVVM contract (e.g., 1 *
seeMateReward()). - The
_priorityFeeForFisher, if it was greater than zero and successfully paid in Step 5. - An additional amount calculated based on the withdrawn offer's value: 0.125% of the
amountstored inusernameOffers[_username][_offerID]. (This is derived from the 0.5% fee structure associated with the offer).
- A base MATE reward, typically fetched from the EVVM contract (e.g., 1 *
- Nonce Management: Marks the NameService
_nonce(provided as input parameter) as used for the_useraddress within themateNameServiceNoncemapping to prevent replay of this specific accept action.