Punk Domains allow anyone to either create a top-level domain (TLD) such as .wagmi
or a normal domain such as techie.wagmi
. In addition, users can add some other data to their domain:
- description
- redirect URL (useful together with the Punk Domains browser extension)
- profile picture (an address and token ID of an NFT)
See instructions below to run the code on localhost and for blockchain deployment.
Create a .env
file with the following keys:
ALCHEMY_API_KEY_MUMBAI=enter-key-here
ALCHEMY_API_KEY_OPTIMISM=enter-key-here
ALCHEMY_API_KEY_RINKEBY=enter-key-here
ALCHEMY_API_KEY_ROPSTEN=enter-key-here
DEPLOYER_PRIVATE_KEY=enter-key-here
ETHERSCAN_API_KEY=enter-key-here
POLYGONSCAN_API_KEY=enter-key-here
OPTIMISTIC_ETHERSCAN_API_KEY=enter-key-here
ARBISCAN_API_KEY=enter-key-here
Make sure you use Node.js v19.
npx hardhat compile
npx hardhat test
Run tests in a specific folder:
npx hardhat test test/factories/flexi/*test.js
Run a specific test:
npx hardhat test test/factories/flexi/TLD.owner.test.js
Start a localhost node:
npx hardhat node
Make sure to add one of the private keys presented as deployer key in .env
file.
In a separate terminal tab then run the following command:
npx hardhat run scripts/deploy.js --network localhost
npx hardhat run scripts/deploy.js --network polygonMumbai
npx hardhat run scripts/deploy.js --network ropsten
Make sure to enter correct network names (see here and here):
etherscan: {
apiKey: {
polygonMumbai: process.env.POLYGONSCAN_API_KEY,
ropsten: process.env.ETHERSCAN_API_KEY
}
},
Then run this command:
npx hardhat verify --network mumbai <contract-address> "argument"
Also make sure you have the @nomiclabs/hardhat-etherscan
library 3.1.0
or above.
Verifying TLD contracts generated through the factory is a bit tricky, but there is a way around the issue. See scripts/temp/deployTld.js
for instructions.
- Flatten the code (
npx hardhat flatten <path-to-contract>.sol >> <flat-contract-name>.sol
). - Delete all instances of SPDX Licences except one.
- Go to Etherscan and select single file verification.
- Turn on optimizations.
- Select 0.8.4 for compiler (do not delete other pragma solidity lines in the file, even if they are for a different Solidity version).
- Generate the ABI-encoded constructor arguments using this online tool: https://abi.hashex.org/. Make sure you generate all arguments needed in the TLD constructor, including the Factory address.
- Submit for verification and hope for the best :)
Most audit tools will require you to flatten the contracts. This means that all contracts that are defined under the imports will actually be imported into one .sol file, so all code is in one place.
First create a new folder called flattened:
mkdir flattened
To flatten a contract, run this command:
npx hardhat flatten <path-to-contract> >> flattened/<flat-contract-name>.sol
You may also need to give all contracts in the flattened file the same Solidity version. And you may need to delete all SPDX lines except the very first one.
Use Docker:
sudo docker pull mythril/myth
Go to the flattened
folder and run this command:
sudo docker run -v $(pwd):/tmp mythril/myth -v4 analyze /tmp/<flat-contract-name>.sol --max-depth 10
Or, if you don't use Docker, use this command alone:
myth -v4 analyze flattened/PunkForbiddenTlds.sol --max-depth 10
Flags:
v4
: verboseo
: outputa
: address onchainl
: automatically retrieve dependenciesmax-depth
: maximum recursion depth
Docs: https://mythril-classic.readthedocs.io/en/master/security-analysis.html
Install Slither:
pip3 install slither-analyzer --user
Run it in the flattened
folder:
slither .
Docs: https://github.com/crytic/slither
Run npx hardhat clean
and then npx hardhat compile
.