Skip to main content

removeCustomMetadata

Signature Verification

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: removeCustomMetadata(address user, string memory identity, uint256 key, address originExecutor, uint256 nonce, bytes memory signature, uint256 priorityFeeEvvm, uint256 nonceEvvm, bytes memory signatureEvvm) external

Removes a specific custom metadata entry identified by its slot index. If the removed entry is not the last slot, all subsequent entries are shifted down to maintain array continuity (no gaps). This ensures efficient iteration and consistent slot indexing.

Parameters

Parameter NameTypeDescription
useraddressThe address of the current owner of the identity who is removing the metadata.
identitystringThe registered identity (e.g., username) from which the custom metadata will be removed.
keyuint256The index (zero-based) of the specific custom metadata entry to be removed from the identity's list.
nonceuint256The owner's (user) nonce specific to the Name Service contract (nameServiceNonce) for this removeCustomMetadata action's replay protection.
signaturebytesThe EIP-191 signature from the owner (user) authorizing this remove metadata action.
priorityFee_EVVMuint256Optional 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_EVVMuint256Required. The owner's (user) nonce for the EVVM payment call used to pay the Metadata Removal Fee + Priority Fee.
priorityFlag_EVVMboolRequired. Priority flag (sync/async) for the EVVM payment call paying the fees.
signature_EVVMbytesRequired. The owner's (user) signature authorizing the EVVM payment call paying the Metadata Removal Fee + Priority Fee.
Signature Links & EVVM Payment
  • The EVVM payment signature (signature_EVVM) covers the total amount (calculated Metadata Fee + priorityFee_EVVM) and is paid by the identity owner (user). It uses the Single Payment Signature Structure. Since a metadata fee is always required, these EVVM parameters are mandatory.
  • The Name Service remove custom metadata signature (signature) must be generated by the current owner (user) and follows the Remove Custom Metadata Signature Structure.
  • The metadata fee is calculated dynamically as 10 times the current EVVM reward amount via getPriceToRemoveCustomMetadata().

Metadata Pricing

The cost to remove custom metadata is calculated dynamically based on the current EVVM reward amount:

Metadata Removal Fee = 10 * getRewardAmount()

This ensures the pricing scales with the network's current reward structure and maintains consistency with other protocol fees.

Workflow

Failure at validation steps typically reverts the transaction. The steps execute in the specified order.

  1. Identity Ownership Verification: Checks if the provided user address is the registered owner of the identity. Reverts if user is not the owner.
  2. Name Service Nonce Verification: Calls internal verifyAsyncNonce(user, nonce) which reverts with AsyncNonceAlreadyUsed() if the nonce was already used.
  3. Remove Custom Metadata Signature Validation: Verifies the signature provided by user (the owner) against the reconstructed message hash using verifyMessageSignedForRemoveCustomMetadata. Reverts if the signature is invalid according to the Remove Custom Metadata Signature Structure.
  4. Custom Metadata Index Validation: Checks that the provided key (index) is valid, meaning it is less than the current number of metadata entries for the identity (key < identityDetails[identity].customMetadataMaxSlots). Reverts if the index is out of bounds.
  5. Payment execution: Calls makePay to transfer the payment using the getPriceToRemoveCustomMetadata() function and priorityFee_EVVM of principal tokens from user to the service via the EVVM contract. Reverts if the payment fails.
  6. Custom Metadata Removal: Removes the metadata entry at the specified key index for the identity. The removal process involves two scenarios:
    • If key == customMetadataMaxSlots (Last element): Directly deletes the metadata entry at identityCustomMetadata[identity][key].
    • If key < customMetadataMaxSlots (Not the last element):
      • Iterates from i = key up to customMetadataMaxSlots - 1.
      • In each iteration, copies the metadata entry from index i + 1 to index i (identityCustomMetadata[identity][i] = identityCustomMetadata[identity][i + 1]).
      • Deletes the entry at the last occupied index (identityCustomMetadata[identity][customMetadataMaxSlots]) to clear the duplicated data.
  7. Decrement Count: Decreases the metadata count: identityDetails[identity].customMetadataMaxSlots-- to reflect the removal.
  8. Nonce Management: Calls internal markAsyncNonceAsUsed(user, nonce) to mark the provided nonce as used and prevent replays.
  9. 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 to msg.sender. The rewards consist of:
    • 5 times the base reward amount (5 * Evvm(evvmAddress.current).getRewardAmount()).
    • The full priorityFee_EVVM, if it was greater than zero and successfully paid in Step 5.