Coder Social home page Coder Social logo

erc721a-nft-eip2981-royalties's Introduction

ERC721A with EIP-2981 Royalties and Dutch auction selling.

ERC721A NFT contract for a 10k pfp project for efficient and cheaper batch minting

I chose the ERC721A implementation to try out how its batch minting capabilities affects gas costs on miniting. To see a full comparison between OpenZeppelin`s ERC721 and ERC721A, see my other repo

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. The logic for the Royalties is outside of the contract and the NFT contract inherits from the implementation.

Other features:

  • 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. It allows to withdraw all ETH from the contract to the Owner address

Some basic Waffle tests are included, as well as a gas report from hardhat-gas-reporter. ERC721A is very efficient for batch minting, so I am including a gas report to see the difference in gas cost when minting 1, 5 and 10 NFTs

  • General report gasreport
  • Mint 1 NFT gasreport
  • Mint 5 NFTs gasreport
  • Mint 10 NFTs 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**

erc721a-nft-eip2981-royalties's People

Contributors

ipastorsan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.