preRegistrationUsername
Function Type: public
Function Signature: preRegistrationUsername(address,bytes32,uint256,bytes,uint256,uint256,bool,bytes)
Function Selector: 0x393b9c6f
Pre-registers a username hash to prevent front-running attacks during the registration process. This function creates a temporary reservation that can be registered after a 30-minute waiting period. The function uses a commitment-reveal scheme where users first commit to a hash of their desired username plus a secret number.
Parameters
Parameter | Type | Description |
---|---|---|
user | address | The address of the end-user initiating the pre-registration. |
hashPreRegisteredUsername | bytes32 | The pre-commitment hash calculated as keccak256(abi.encodePacked(username, clowNumber)) . |
nonce | uint256 | The user's nonce specific to this NameService contract for replay protection of this pre-registration action. |
signature | bytes | The EIP-191 signature from user authorizing this pre-registration action. |
priorityFee_EVVM | uint256 | Optional fee (in principal tokens) paid by user to the msg.sender (staker executing the transaction) via the EVVM contract. |
nonce_EVVM | uint256 | Required if priorityFee_EVVM > 0 . user 's nonce for the EVVM payment function call used only to pay the priority fee. |
priorityFlag_EVVM | bool | Required if priorityFee_EVVM > 0 . Priority flag (sync/async) for the EVVM payment call paying the priority fee. |
signature_EVVM | bytes | Required if priorityFee_EVVM > 0 . user 's signature authorizing the EVVM payment call paying the priority fee. |
- The EVVM payment signature (
signature_EVVM
) is only needed if paying a priority fee and follows the Single Payment Signature Structure. - The NameService pre-registration signature (
signature
) follows the Pre-Registration Signature Structure. - The EVVM parameters (
nonce_EVVM
,priorityFlag_EVVM
,signature_EVVM
) are only required and processed ifpriorityFee_EVVM
is greater than zero.
Hash Username Structure
The hashPreRegisteredUsername
is calculated off-chain by the user using SHA3-256 (keccak256):
keccak256(abi.encodePacked(username, clowNumber));
Where:
username
(string): The desired username.clowNumber
(uint256): A secret number chosen by the user, required later during theregistrationUsername
step to validate the commitment.
Execution Methods
This function can be executed by any address, with staker rewards only distributed to stakers.
Fisher Execution
When the executor is the fisher:
- The user sends the payment request to the fishing spot
- The fisher captures the transaction and validates all parameters
- The fisher submits the transaction to the contract for processing
Direct Execution
When the executor is the user or a service:
- The user/service submits their transaction directly to the contract
Workflow
-
NameService Nonce Verification: Checks if the provided
nonce
is unused for theuser
using theverifyIfNonceIsAvailable
modifier. Reverts if used. -
Pre-registration Signature Verification: Verifies the
signature
provided byuser
usingverifyMessageSignedForPreRegistrationUsername
. Reverts withInvalidSignatureOnNameService
if invalid. -
Priority Fee Processing: If
priorityFee_EVVM > 0
, calls themakePay
function to process the priority fee payment through EVVM using the provided EVVM parameters. -
Hash Storage: Records the pre-registration by storing the
hashPreRegisteredUsername
with:- Key:
"@" + hashPreRegisteredUsername
(converted to string) - Owner:
user
- Expiration:
block.timestamp + 30 minutes
- Flags: Marked as not a username (
flagNotAUsername = 0x01
)
- Key:
-
Nonce Management: Marks the NameService
nonce
as used for theuser
in thenameServiceNonce
mapping. -
Staker Rewards: If the executor (
msg.sender
) is a staker (isAddressStaker(msg.sender)
), distributes rewards viamakeCaPay
:- Base MATE reward (
getRewardAmount()
) - Plus the
priorityFee_EVVM
amount
- Base MATE reward (