flushUsername
This function uses Core.sol's centralized signature verification via validateAndConsumeNonce(). All NameService operations use the universal signature format with NameServiceHashUtils for hash generation.
Function Type: External
Function Signature: flushUsername(address user, string memory username, address originExecutor, uint256 nonce, bytes memory signature, uint256 priorityFeeEvm, uint256 nonceEvvm, bytes memory signatureEvvm) external
Permanently deletes a username registration and all associated data. This is irreversible - the username becomes immediately available for others to register. All custom metadata is deleted, ownership is reset, and the username returns to initial state (except offerMaxSlots is preserved for historical tracking).
Parameters
| Parameter Name | Type | Description |
|---|---|---|
user | address | The address of the current owner of the username who is authorizing the permanent deletion. |
username | string | The registered identity (e.g., username) to be permanently flushed from the system. |
nonce | uint256 | The owner's (user) nonce specific to the Name Service contract (nameServiceNonce) for this flushUsername action's replay protection. |
signature | bytes | The EIP-191 signature from the owner (user) authorizing this flush username action. |
priorityFee_EVVM | uint256 | Optional fee (in principal tokens) paid by the owner (user) to the msg.sender (executor) via the EVVM contract for prioritized processing of this transaction. |
nonce_EVVM | uint256 | Required. The owner's (user) nonce for the EVVM payment call used to pay the total calculated Flush Fee + Priority Fee. |
priorityFlag_EVVM | bool | Required. Priority flag (sync/async) for the EVVM payment call paying the fees. |
signature_EVVM | bytes | Required. The owner's (user) signature authorizing the EVVM payment call to transfer the total calculated Flush Fee + Priority Fee. |
- The EVVM payment signature (
signature_EVVM) covers the total amount (calculated Flush Fee +priorityFee_EVVM) and is paid by the identity owner (user). It uses the Single Payment Signature Structure. Since a flush fee is required, these EVVM parameters are mandatory. - The Name Service flush username signature (
signature) must be generated by the current owner (user) and follows the Flush Username Signature Structure. - The flush fee is calculated as the sum of metadata flush cost plus a base username deletion fee via
getPriceToFlushUsername(username).
Username Flush Pricing
The cost to flush a username is calculated dynamically based on the current EVVM reward amount and includes both metadata removal and username deletion costs:
Flush Fee = ((10 * getRewardAmount()) * customMetadataMaxSlots) + getRewardAmount()
This pricing includes:
- Metadata removal cost: 10x reward amount per metadata entry
- Base username deletion fee: 1x reward amount
Workflow
Failure at validation steps typically reverts the transaction. The steps execute in the specified order.
- Name Service Nonce Verification: Calls internal
verifyAsyncNonce(user, nonce)which reverts withAsyncNonceAlreadyUsed()if the nonce was already used. - Identity Ownership Verification: Checks if the provided
useraddress is the registered owner of theusername. Reverts ifuseris not the owner. - Username Expiration and Type Validation: Validates that the username has not expired and is a valid username type:
- Checks that
block.timestamp < identityDetails[username].expireDate(username is still active) - Checks that
identityDetails[username].flagNotAUsername == 0x00(it's a username, not another type of identity) - Reverts with
FlushUsernameVerificationFailedif either condition fails.
- Checks that
- Flush Username Signature Validation: Verifies the
signatureprovided byuser(the owner) against the reconstructed message hash usingverifyMessageSignedForFlushUsername. Reverts if the signature is invalid according to the Flush Username Signature Structure. - Payment Execution: Calls
makePayto transfer the payment usinggetPriceToFlushUsername(username)andpriorityFee_EVVMof principal tokens fromuserto the service via the EVVM contract. Reverts if the payment fails. - Custom Metadata Removal: Iterates through all metadata entries and deletes them:
- Loops from
i = 0tocustomMetadataMaxSlots - 1 - Deletes each entry:
delete identityCustomMetadata[username][i]
- Loops from
- Reward Distribution (to Executor): Calls an internal helper function (
makeCaPay) to distribute rewards in principal tokens directly tomsg.sender(the executor). The rewards consist of:- 5 times the base reward amount multiplied by the number of metadata entries (
(5 * getRewardAmount()) * customMetadataMaxSlots). - The full
priorityFee_EVVM, if it was greater than zero and successfully paid in Step 5.
- 5 times the base reward amount multiplied by the number of metadata entries (
- Username Registration Reset: Resets the username registration data while preserving offer slots:
- Sets
ownertoaddress(0) - Sets
expireDateto0 - Sets
customMetadataMaxSlotsto0 - Preserves existing
offerMaxSlots - Sets
flagNotAUsernameto0x00(making it available for re-registration)
- Sets
- Nonce Management: Calls internal
markAsyncNonceAsUsed(user, nonce)to mark the providednonceas used and prevent replays.