npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gwei-slim-nft-contracts

v1.0.3

Published

GWEI Slim NFT Base Contracts

Downloads

16

Readme

Save on ⛽️ writing custom NFT contracts

| 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:

  1. ERC2981 royalties
  2. BaseURI and tokenID string generation for fixed-sized collections.
  3. 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.

Getting started

  1. Clone the example repository: https://github.com/iainnash/example-gwei-optimized-minting-contract
  2. Update the contract code with your custom NFT contract information
  3. Ensure base NFT contract address is set in hardhat.config.ts for your network
  4. hardhat deploy --network NETWORK --tags MY_CONTRACT replacing YOUR_CONTRACT with your contract and NETWORK with the desired network.

Current Deployments:

Example Contract Deployed

  • child implementation: https://rinkeby.etherscan.io/address/0x83FA6bfdF5920816a4cF9230D32049372F6E06eA

  • base: https://rinkeby.etherscan.io/address/0x86c67a16C16BF784BdFE7D4b7575dB664D191F88

How do I get started?

  1. Clone this repo
  2. Update your desired ChildNFT class
  3. Delete all unused ChildNFT examples and deployments
  4. Add address to deployed base ERC721Base to hardhat.config.ts
  5. hardhat deploy --network rinkeby --tags ChildNFT

Features

Things you now can get for no additional gas when writing your own NFT contracts:

  1. 4x (!) lower deployment cost in gas
  2. ERC2981 built-in option to enable, more complex usages can override the reading function
  3. URI + ID functionality built-in, able to override and reset base URIs
  4. Ability to gate transfer, burn, mint, or disable certain functionality when needed
  5. totalSupply without full enumerable interface implementation
  6. More legible "special" functionality on top of base NFT contract for readers
  7. Ability to verify contracts and add custom comments functionality without being beholden to a factory contract's rules.

Gotchyas

  1. ABIs need to be combined manually or use both contract interfaces for typechain (working on a fix soon)
  2. Native ERC721 functions will be shown as a "Contract Proxy" on etherscan