Git Product home page Git Product logo

erc721psi's Introduction

ERC721Psi

Node.js CI Publish Package to npmjs Build Documentation npm version

ERC721Psi is an ERC721 compliant implementation designed for scalable and gas-efficient on-chain application with built-in randomized metadata generation.

Inspired by AzukiZen's awesome ERC721A, ERC721Psi also provides batch minting at a fixed gas cost. However, ERC721Psi manages to solve the scaling issue of token transfer through the mathematical power of the de Bruijn sequence.

If your application doesn't require a specific ERC721 interface, you may be interested in checking ERC1155Delta which provides even more gas savings than ERC721Psi.

ERC721Psi is releasd under MIT opensource licence and is free to use. If you need commercial support/service regarding ERC721Psi, feel free to contact ctor.xyz

Powered by Chainlink's VRF V2, ERC721Psi comes with an extension that can batch mint multiple tokens with tamper-proof on-chain random attributes while retaining the fixed minting gas cost.

Litepaper: mirror.xyz/ctor.xyz/zy3TUWuJFSeWyMWAucTRP45o-sVToKTrtDsUIiD_m48

Slides: slideshare.net/EstarriolVetch/erc721psi

Docs: estarriolvetch.github.io/ERC721Psi/

Installaion

npm

npm install --save-dev erc721psi

yarn

yarn add --dev erc721psi

Usage

pragma solidity ^0.8.0;

import "erc721psi/contracts/ERC721Psi.sol";

contract Adventurer is ERC721Psi {

    constructor() 
        ERC721Psi ("Adventurer", "ADVENTURER"){
    }

    function mint(uint256 quantity) external payable {
        // _safeMint's second argument now takes in a quantity, not a tokenId. (same as ERC721A)
        _safeMint(msg.sender, quantity);
    }

}

Random Seed Extension

The random seed extensions provide an easy way for NFT projects to create on-chain randomized metadata at the individual token level.

The random seed extensions use Chainlink's VRF V2 as its source of randomness. Each token comes with its own unique seed that can be used to derived its attributes.

interface IERC721RandomSeed {
    function seed(uint256 tokenId) external view returns (uint256);
}

There are two types of random seed extensions with different schemes of requesting randomness.

  • ERC721PsiRandomSeed: The randomness is requested during minting. There is no extra actions required for the project owner to reveal the token. The random seeds of the tokens will be revealed when the randomness request is fulfilled by the Chainlink nodes.
  • ERC721PsiRandomSeedReveal: The randomness is requested when the _reveal() function is called. This function is usually called by the project owner to reveal the tokens. Everytime _reveal() is called, it will reveal the random seeds of all the tokens minted since the last reveal.

Considerations

It is important to realize that balanceOf, totalSupply, tokenByIndex, and tokenOfOwnerByIndex in ERC721Psi are not designed to be gas efficient since they are mostly used by front end only. By doing so, we are able to reduce the storage usage and thus minimize the gas consumption for the rest of the functions.

If tracking balanceOf on-chain is important for your application, please use the ERC721PsiAddressData extension.

Road Map

  • Implement more extensions.
  • Add more test cases.
  • Build an contract wizard (like this) for generating the contract skeleton.

Contributors

PRs on documentation, test cases, and contract improvements are welcome.

Projects using ERC721Psi

If your project uses ERC721Psi, we'd like know more about it!

Feel free to DM 0xEstarriol to share your project.

Library built on ERC721PSi

NFT Project

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.