Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 3.2 KB

README.md

File metadata and controls

70 lines (49 loc) · 3.2 KB

Basic NFT Contract with EIP-2981 Royalties

This is a basic NFT contract designed with a 10k pfp project in mind.

This repo is focused on the implementation of an Allowlist using a precomputed Merkle Tree root. It uses Openzeppelin cryptography library

This Merkle Tree implementation assumes that your front end will be querying an external API for the Merkle Proof that will be later checked inside the contract.

If you want a simple implementation of such API in AWS, I would recommend to check out this Medium Article by Alan, as well as his Github Repo

Other features:

  • EIP-2981 royalties. Set to send 5% of sales proceeds to the deployer of the contract. Note that even if I am using (owner()) in the constructor, this is a piece of information that needs to be overwritten calling setRoyalties if the contract change Owner.
  • openPublicSale() to grant the deployer more control on the minting process, it needs to be called for the minting to happen.
  • Max-tokens-per-wallet and max-tokens-per-mint. Avoid that any single wallet hoards all your collection. This can be bypassed spunning new wallets, but its annoying and the minter has to pay gas fees repeatedly.
  • `````CallerIsUser```` modifier to only allow calls from EOA, not from other smart contracts. This is used to avoid certain exploits.
  • reveal() function to change the baseTokenUri and improve the fairness of minting.
  • withdraw() function. This allows to withdraw all ETH from the contract to the Owner.

The Waffle tests include the allowlist functions, precomputing the root from the default addresses that Hardhat provides, as well as a gas report from hardhat-gas-reporter

gasreport

Useful commands to run the project

You need to have Node.js (>=12.0)installed in your computer You can find it here

Install project dependencies

npm install

Install dotenv to store environment variables and keep them secret

You need at least these variables in your .env file. BE SURE TO ADD IT TO GITIGNORE

This is not compulsory, you could use public RPC URL, but Alchemys work really well and their free tier is more than enough (not sponsored)

  • DEVELOPMENT_ALCHEMY_KEY = "somestringhere"
  • PRODUCTION_ALCHEMY_KEY = "somestringhere"

Keys for deployment

  • PRIVATE_KEY_DEVELOPMENT = "somenumberhere"
  • PRIVATE_KEY_PRODUCTION = "somenumberhere"

To verify the contracts on Etherscan/polyscan etc

  • ETHERSCAN_KEY = "anothernumberhere"

Use the project

deploy contract

run with this for testing:

npx hardhat run scripts/deploy-script.js --network rinkeby 

run with this for mainnet:

npx hardhat run scripts/deploy-script.js --network mainnet

Run tests

npx hardhat test test/test.js 

Verify contract

npx hardhat verify --network **networkhere** **contractAddress**