Hardhat NFT Smart Contract
This smart contract is for minting NFTs and has features for allowlist mint and public mint. Since ERC721A is used, it significantly reduces gas (you can mint multiple NFTs at essentially the same cost as minting a single NFT!). Besides that, it is designed to reduce gas as much as possible.
More features:
- A mocked contract for testing
- An unit test example for testing the contracts
- Automatically verify the source code for the contract on Etherscan when deploying
- A feature for updating shared files on the front end (dApp)
- Scripts for opening allowlist/public sale, close sales, and reveal your collection
1 . Clone this repo:
git clone https://github.com/kjmczk/hardhat-nft-smart-contract.git
2 . Change into the directory:
cd hardhat-nft-smart-contract
3 . Install dependencies:
npm install
4 . Set up environment variables:
cp .env.example .env
Replace the values of the variables you need in the .env
file with yours.
5 . Set up project-config.ts
:
- Replace the file paths with yours
- Replace
hiddenMetadataUri
with yours
npx hardhat test
1 . Network: hardhat(default)
:
npx hardhat deploy
2 . Network: localhost
:
npx hardhat node
Launch another terminal and run the following command:
npx hardhat deploy --network localhost
3 . Network: rinkeby/mainnet/mumbai/polygon
:
npx hardhat deploy --network <networkName>
4 . Tags
:
Deploying without the --tags <tags>
option runs all deploy scripts in the deploy
directory.
For example, if you want to run only deploy/02-update-front-end.ts
using the rinkeby
network:
npx hardhat deploy --network rinkeby --tags updateFrontEnd
The tag name is set at the bottom of the deploy script file.
Using Hardhat Network and running only
deploy/02-update-front-end.ts
will result in an error.
1 . Open allowlist sale:
npm run open-allowlist -- --network <networkName>
2 . Open public sale:
npm run open-public -- --network <networkName>
3 . Close sales:
npm run close -- --network <networkName>
4 . Reveal collection:
npm run reveal -- --network <networkName>
A sample dApp for this contract is available!