VNRS stands for Vanity Name Registration System
. It is a front-running resistant smart contract application to register vanity names on Ethereum.
- The user creates a commitment corresponding to the name he wants to register with a secret. It is a hash of user's address, name and secret.
- The user commits the commitment obtained in #1.
- The user calls
register
function afterMIN_COMMITMENT_AGE
but beforeMAX_COMMITMENT_AGE
with the amount to be locked forNAME_LOCKING_DURATION
(30 days).Registered
event is emitted which denotes that the name is registered.
npm install
npx hardhat compile
npx hardhat test
- How do you prevent front-running attacks?
- By using commit & reveal mechanism
- Why is a minimum delay period of 1min required?
- So that the reveal transaction is included in a different block than the commit transaction
- How happens when user renews his registration?
- He doesn't have to pay the fees again and his initial amount are locked for another 30 days.
- How does the commit & reveal mechanism prevent front-running attacks?
The best remediation is to remove the benefit of front-running in your application, mainly by removing the importance of transaction ordering or time.
- Consensys Smart Contract Best practices guide.- The commit transaction commits to the hash of the
vanity name
,user address
and asecret
string. - After the above transaction is included in the blockchain, the reveal transaction checks if the commitment is valid. If it's valid, the logic for name registration is carried out.