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

@ikalasdev/erc721generator

v1.0.11

Published

npm package that allow the user to generate a ERC721 token to create NFT

Downloads

13

Readme

ERC721Generator

ERC721Generator is a npm librairy that allow the developper to create, deploy and use customisable ERC721 contract. You can create NFT collections or add NFTs to an existing contract.

Prerequirements:

This is a Node.js module available through the npm registry. Before installing, download and install Node.js. If this is a brand new project, make sure to create a package.json first with the npm init command.

Installation

  1. This module need to be in a hardhat project.
    create hardhat project with
npm install hardhat --save-dev
npx hardhat
  1. install the module using
npm install @ikalasdev/erc721generator

check soldity compiler version is >= 0.8.0 in hardhat.config.js

By default, the basic hardhat project include hardhat-waffle. If this requirement is missing, this at the begining of the hardhat.config.js file:

require('@nomiclabs/hardhat-waffle')

and download the library with :

npm install @nomiclabs/hardhat-waffle

Network

For this library there is no needs to setup the network.

Examples

Generate a contract and get informations about

The function create() allow to create a fully customisable ERC721 contract and get the informations such as the abi, the bytecode and the source code of the contract. This function doesn't deploy the contract.

Setup the function :

const generator = require('@ikalasdev/erc721generator');

//All options available
options= 
[
    "mintable",
    "pausable",
    "burnable",
    "enumerable",
    "uri",
    "autoincrement",
    "votes"
];

var contractName = "myERC721Contract"; //represent the name of the token

Call the function :

const generator = require('@ikalasdev/erc721generator');

//first option
generator.create(contractName, options)
.then(function(result) {
    console.log(result);
});

//second option
let contractInfos = await generator.create(contractName, options)

Create and deploy a contract

The function deploy() allow to create a fully customisable ERC721 contract and deploy it on a blockchain.

Setup the function :

//All options available for the contract
options= 
[
    "mintable",
    "pausable",
    "burnable",
    "enumerable",
    "uri",
    "autoincrement",
    "votes"
];

var contractName = "myERC721Contract"; //represent the name of the token
var symbol = "ERC"; //represent the acronym of the token like ETH, BTC,...
var privateKey = "123...456"; //represent the private key of your wallet (you can use a .env file to keep it secret)
var urlRPC = "https://data-seed-prebsc-1-s1.binance.org:8545/"; //represent the url of a specific blockchain, you can get your url for a blockchain on : https://infura.io  

Call the function :

const generator = require('@ikalasdev/erc721generator');

// First Option
generator.deploy(contractName, symbol, options, privateKey, urlRPC).then(function(result) {
    console.log(result);
});

// Second option
let contractInfos = await generator.deploy(contractName, symbol, options, privateKey, urlRPC)

Create collection

The function createCollection() allow to generate a new ERC721 contract and mint NFTs directly after that.

Setup the function :

var name = "mytoken"; //represent the name of the token
var symbol = "MT"; //represent the acronym of the token like ETH, BTC,...
var privateKey = process.env.PRIVATE_KEY; //represent the private key of your wallet (you can use a .env file to keep it secret)
var urlRPC = "https://rinkeby.infura.io/v3/${INFURA_KEY}"; // represent the RPC url of your network 
var chainId = 1; //represent the chainId of the blockchain of your RPC.

// represent the urls redirecting to the metadatas of the NFT created. Make sure that they are unalterable.
// The first URL is in the web2.0 with npoint and the second one is hosted on IPFS ( you can use https://gateway.pinata.cloud/ to host you ipfs nft)
var metadatas = ["https://api.npoint.io/b0dc5aee2255e5f0ee60", "https://ipfs.io/ipfs/QmZWLYEpNJt1kji5v4Doz9vUvoGjakgXsHpo8en3akxMsM"]; 

var isTestnet = false; //if you are using a testnet you have to set this to true (this parameter is just to return the good opensea link between testnet and mainnet)
var owner = "0x123...321"; // represent the account that will have the nfts


//Create a instance of collection class
const mycollection = new Collection(name, symbol, privateKey, urlRPC, chainId, metadatas, isTestnet, owner);

Call the function :

const generator = require('@ikalasdev/erc721generator');

//First option
generator.createCollection(mycollection).then(function (result) {
    console.log(result);
});

//Second option
let collectionInfos = await generator.createCollection(myCollection);