This is a solidity contract for a basic NFT with mint price, token supply limit, and royalties based on OpenZeppelin ERC721 and extensions. It is built with node js, npm, and hardhat and includes unit tests.
Report Bug
·
Request Feature
Table of Contents
This is an example of how you may set up this project locally, if you like. To get a local copy up and running follow these simple example 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 -gFeel free to use the contract without going through all of these steps. But, follow the instructions below if you would like to install the project on your local machine so you can see the unit testing results, generate gas reports, see testing coverage, and deploy to a testnet or real net with this code, or just tinker around with hardhat (see the Patrick Collins video link in the acknowledgments at bottom).
-
Create a directory on your local machine where you want the project, then navigate to that directory.
-
Clone the repo
git clone https://github.com/your_username_/Project-Name.git- Install NPM packages. This command will look in the package.json folder and install the needed dependencies.
npm install- Make your own .env file as depicted below, substituting the real info where you see lowercase in the example below. Then save it in the top level of the directory. The gitignore file contains .env so this info will not go to the repo. You will need to obtain API keys from several websites to accomplish this. Security: Notice that you DO NOT see my .env file pushed to the repo. This is for a reason. Keep these values secret and DO NOT push them to github. And PLEASE DO NOT use a Metamask wallet that has real currency in it. Make a new wallet that will never hold real currency and use it for the testing. If you are only planning to use the hardhat network, and not a testnet, there is no need to provide any of the info in this file (unless you want gas reports in USD, then provide the coinmarketcap info).
REPORT_GAS=true
ETHERSCAN_API_KEY=enter you etherscan api key here
ALCHEMY_API_KEY=enter your Alchemy api key here
STUNT_WALLET_ADDRESS=enter your Metamask testing wallet address here (don't use a wallet with real currency)
STUNT_WALLET_PRIVATE_KEY=enter your Metamask testing wallet private key here (don't use a wallet with real currency)
COINMARKETCAP_API_KEY=enter your coinmarketcap api key here
POLYGONSCAN_API_KEY=enter you polygonscan API api here- To compile the contract:
npx hardhat compile- To run unit tests:
npx hardhat testThe results will be displayed in the terminal window. A gas report will be generated and written to .gas-report.txt'. If you have provided a coinmarketcap api key, then USD values will be provided.
- To generate coverage report:
npx hardhat coverageThe results will be displayed in the terminal window. Fancier reports will be stored in a directory called 'coverage'. A great way to view them is the spin up a local http server and open index.html in the 'coverage' directory.
- To deploy:
npm run deployThe terminal will display several messages as the contract deploys, verifies (if on a testnet), and mints three tokens. You should then be able to search that contract address on OpenSea testnet and view the tokens. Look in notes.txt to see the results from my attempt in late July. You can try the links there, but they may not persist.
- Please provide feedback to me if you see any errors in these instructions, the code, or the repo at large. Happy hardhatting!
You may confidently download and use this contract (courseNFTContract.sol), which has been verified, in your own NFT projects. This is really designed to be used from a front end that will make the appropriate calls to compile, deploy and interact with the contract, generate the digital art and upload it to IPFS, and pass in the proper IPFS URLs to the contract and to each token as minted.
See my other repo for a full stack working project - coming soon. Full stack project
- Set NFT price at depoyment
- Set token supply limit at deployment
- Set metadata (IPFS link) at deployment
- Unit tested with Hardhat toolbox
- Staging tested on Mumbai and OpenSea test network
See the open issues for a full list of proposed features (and known issues).
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
Distributed under the MIT License. See LICENSE.txt for more information.
David G. Smith - @davidgailsmith - david@davidgailsmith.com
Project Link: https://github.com/dgsmith7/NFT-Contract
