Table of Contents
Contract Address
0x6b3198d1a1b29156A2a99f01948e298A64bb86a3
Smart Contract Registered to Oracle testnet for checking expiration of name registration after every 24 hours automatically
Step: 1
Step: 2
Step: 3
Blockchain technology enables decentralized applications (DApps) or smart contracts. Function calls (or transactions) to the DApp are processed by a decentralized network. Transactions are finalized in stages: they (generally) first relay around the network, then are selected by a miner and put into a valid block, and finally, the block is well-enough incorporated in the blockchain that is unlikely to be changed. Front-running is an attack where a malicious node observes a transaction after it is broadcast but before it is finalized, and attempts to have its own transaction confirmed before or instead of the observed transaction.
In this application I followed Consensys provided guideline to prevent frontrun and malicious activities by validator. Suggestion is to store the keccak256 hash of the data in the first transaction, then reveal the data and verify it against the hash in the second transaction.
Front-running and malicious node/validator resistant smart contract, written in Solidity to register vanity names/domains on EVM Blockchains. An unregistered name can be registered for a certain amount of time by locking a certain balance of an account. After the registration expires, the account loses ownership of the name and his balance is unlocked. The registration can be renewed by making an on-chain call to keep the name registered and balance locked. The fee to register the name depends directly on the size of the name. Also, a malicious node/validator should not be able to front-run the process by censoring transactions of an honest user and registering its name in its own public address.
- Solidity
- Node.js
- Openzeppelin
- Chainlink-Oracle
- Truffle Suite
- Hardhat
- Ehers.js
- Chai - as testing library.
To get a local copy up and running follow these simple steps.
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -g
- Clone the repo
git clone https://github.com/rafiul86/Name-Registry-Smart-Contract.git
- Install NPM packages
npm install
Change the secret variables as process.env.SECRET_KEY and process.env.ALCHEMY provided by API provider if deploy to mainnet (Ethereum, Binance, Fantom, Avalanche etc.) or remote testnet(rinkeby, ropsten, goerli etc.)
npx hardhat compile
npx hardhat run --network rinkeby scripts/deploy.js
npx hardhat compile
npx hardhat run --network localhost scripts/deploy.js
npx hardhat test
After running the commands in terminal should show the tests results....
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
None
Rafiul Hasan - Linkedin Twitter - rafiulhasan86@gmail.com
Project Link: https://github.com/rafiul86/Name-Registry-Smart-Contract