@ikalasdev/erc721generator

1.0.11 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i @ikalasdev/erc721generator

Weekly Downloads

1

Version

1.0.11

License

MIT

Unpacked Size

171 kB

Total Files

10

Last publish

Collaborators

  • lechiffre4
  • tlbail
  • malik-ikalas