Contract | Deploy GWEI | % of block size |
---|---|---|
OptimizedChildNFT |
501,064 | 1.6% |
ERC721Base |
1,614,646 | 5.4% |
Deploy your own on-chain metadata NFT contract for only ~500k gwei.
For most NFT projects, the base 80% of NFT code is unchanged from OpenZeppelin. A transparent factory pattern works well when the implementation used is identical between NFT contracts, but what about custom logic and overriding certain portions of standard behavior?
This proxy pattern uses a solidity fallback to call into OpenZeppelin contract code for any undefined functions. When your NFT contract code calls these functions, permission is granted since the contract itself is the caller.
[YourNft] => fallback [BaseNFT]
Any functions on ChildNFT override the default behavior of the standard Openzeppelin ERC721 code. To add logic before or after these functions, the standard _mint
, _burn
and main NFT functions can be accessed by using the base()
getter. This logic is all in DelegatedLogic
contract.
The standard base contract code is loaded in using the delegatecall()
pattern.
A few common additional features for NFT series are included:
- ERC2981 royalties
- BaseURI and tokenID string generation for fixed-sized collections.
- Syntax sugar has been added for calling openzeppelin standard
_
private functions from the contract implementing DelegatedLogic itself.
The deployed base contract OpenZeppelin code can be used to be the underlying implementation for many, many NFT contracts.
- Clone this repository (will publish on NPM after further review)
- Choose a contract to start off in the
/contracts/examples/
folder - Update the deploy folder with your contract information
- Set base NFT contract address in
hardhat.config.ts
hardhat deploy --network NETWORK --tags MY_CONTRACT
replacing YOUR_CONTRACT with your contract and NETWORK with the desired network.
- Better testing and security review
- Deploy
ERC721Base
to mainnet and update address of deployment in this repo.
-
Mainnet: Not yet
-
child implementation: https://rinkeby.etherscan.io/address/0x83FA6bfdF5920816a4cF9230D32049372F6E06eA
-
base: https://rinkeby.etherscan.io/address/0x3Be479A0e8D5732BE5051Bfe6833CC98722f2C1b
- Clone this repo
- Update your desired ChildNFT class
- Delete all unused ChildNFT examples and deployments
- Add address to deployed base ERC721Base to
hardhat.config.ts
hardhat deploy --network rinkeby --tags ChildNFT
Things you now can get for no additional gas when writing your own NFT contracts:
- 3.5x (!) lower deployment cost in gas
- ERC2981 built-in option to enable, more complex usages can override the reading function
- URI + ID functionality built-in, able to override and reset base URIs
- Ability to gate transfer, burn, mint, or disable certain functionality when needed
totalSupply
without full enumerable interface implementation- More legible "special" functionality on top of base NFT contract for readers
- Ability to verify contracts and add custom comments functionality without being beholden to a factory contract's rules.
- ABIs need to be combined manually or use both contract interfaces for typechain (working on a fix soon)
- Native ERC721 functions will be shown as a "Contract Proxy" on etherscan