flushCustomMetadata
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: flushCustomMetadata(address user, string memory identity, address originExecutor, uint256 nonce, bytes memory signature, uint256 priorityFeeEvvm, uint256 nonceEvvm, bytes memory signatureEvvm) external
Removes all custom metadata entries for a username in one transaction. More gas-efficient than calling removeCustomMetadata multiple times. The cost is calculated per entry, making it proportional to the amount of metadata being deleted.
Parameters
| Parameter Name | Type | Description |
|---|---|---|
user | address | The address of the current owner of the identity who is authorizing the flush. |
identity | string | The registered identity (e.g., username) from which all custom metadata entries will be flushed. |
nonce | uint256 | The owner's (user) nonce specific to the NameService contract (nameServiceNonce) for this flushCustomMetadata action's replay protection. |
signature | bytes | The EIP-191 signature from the owner (user) authorizing this flush all metadata 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. |
- 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 always required, these EVVM parameters are mandatory. - The NameService flush custom metadata signature (
signature) must be generated by the current owner (user) and follows the Flush Custom Metadata Signature Structure. - The flush fee is calculated dynamically based on 10 times the current EVVM reward amount for each metadata entry (
getPriceToFlushCustomMetadata(identity)).
Metadata Pricing
The cost to flush all custom metadata is calculated dynamically based on the current EVVM reward amount and the number of metadata entries:
Flush Fee = (10 * getRewardAmount()) * customMetadataMaxSlots
This ensures the pricing scales with both the network's current reward structure and the amount of work required to flush all entries.
Workflow
Failure at validation steps typically reverts the transaction. The steps execute in the specified order.
- Identity Ownership Verification: Checks if the provided
useraddress is the registered owner of theidentity. Reverts ifuseris not the owner. - NameService Nonce Verification: Calls internal
verifyAsyncNonce(user, nonce)which reverts withAsyncNonceAlreadyUsed()if the nonce was already used. - Flush Custom Metadata Signature Validation: Verifies the
signatureprovided byuser(the owner) against the reconstructed message hash usingverifyMessageSignedForFlushCustomMetadata. Reverts if the signature is invalid according to the Flush Custom Metadata Signature Structure. - Empty Metadata Validation: Checks that the identity has at least one metadata entry (
identityDetails[identity].customMetadataMaxSlots > 0). Reverts if there are no metadata entries to flush. - Payment Execution: Calls
makePayto transfer the payment usinggetPriceToFlushCustomMetadata(identity)andpriorityFee_EVVMof principal tokens fromuserto the service via the EVVM contract. Reverts if the payment fails. - Custom Metadata Removal (Flush): Iterates through all metadata entries and deletes them:
- Loops from
i = 0tocustomMetadataMaxSlots - 1 - Deletes each entry:
delete identityCustomMetadata[identity][i]
- Loops from
- Reward Distribution (to Executor): If the executor (
msg.sender) is an sMATE staker, calls an internal helper function (makeCaPay) to distribute rewards in principal tokens directly tomsg.sender. 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 (
- Reset Metadata Counter: Sets
identityDetails[identity].customMetadataMaxSlots = 0to reflect that all metadata has been removed. - Nonce Management: Calls internal
markAsyncNonceAsUsed(user, nonce)to mark the providednonceas used and prevent replays.