npm package: @ikalasdev/erc721generator
Description: npm package that allow the user to generate a ERC721 token to create NFT
Author: HAOUCHET Sahel
Latest version: 1.0.11

# 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](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).
Before installing, [download and install Node.js](https://nodejs.org/en/download/). 
If this is a brand new project, make sure to create a `package.json` first with
the ``npm init``  [command](https://docs.npmjs.com/creating-a-package-json-file).

## Installation

1.  **This module need to be in a** [**hardhat project**](https://hardhat.org/getting-started/).  
[create hardhat project](https://hardhat.org/getting-started/) with 
```
npm install hardhat --save-dev
npx hardhat
```

2. install the module using
```bash
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:
```js
require('@nomiclabs/hardhat-waffle')
```

and download the library with :
```bash
npm install @nomiclabs/hardhat-waffle
```


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

## Examples

### <u>Generate a contract and get informations about</u>
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.</br>

Setup the function : 
```js
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 : 
```js
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)
```



### <u>Create and deploy a contract</u>

The function **deploy()** allow to create a fully customisable ERC721 contract and deploy it on a blockchain.</br>

Setup the function : 
```js
//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 :
```js
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)
```




### <u>Create collection</u>

The function **createCollection()** allow to generate a new ERC721 contract and mint NFTs directly after that.</br>

Setup the function : 
```js
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 : 
```js
const generator = require('@ikalasdev/erc721generator');

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

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



```

<!--### <u>Add NFTs to a collection</u>

The function **addNFTs()** allow to generate new NFTs on an existing contract.</br>

With promises :
```js
const generator = require('@ikalasdev/erc721generator');

var contractAddress = "0x123...321"; //represent the address of the existing ERC721 contract
var contractABI = ["..."]; //represent the ABI of the existing contract
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  
var metadatas = ["https://api.npoint.io/b0dc5aee2255e5f0ee60","https://api.npoint.io/fb59de34f5a19e0b6598"]; //represent the urls redirecting to the metadatas of the NFT created. Make sure that they are unalterable.
var ownerAddress = "0x123...321" //represent the owner of the NFT created. This parameter is not mandatory. By default, the owner is owner of the privateKey.

generator.addNFTs(contractAddress, contractABI, privateKey, urlRPC, metadatas, ownerAddress);
```

with async function : 
```js
const generator = require('@ikalasdev/erc721generator');


var nameOfTheToken = "NameOfTheToken"; //represent the name of the token
var signOfTheToken = "NOTT"; //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  
var metadatas = ["https://api.npoint.io/b0dc5aee2255e5f0ee60","https://api.npoint.io/fb59de34f5a19e0b6598"]; //represent the urls redirecting to the metadatas of the NFT created. Make sure that they are unalterable.
var ownerAddress = "0x123...321" //represent the owner of the NFT created. This parameter is not mandatory. By default, the owner is owner of the privateKey.

let variable = await generator.addNFTs(contractAddress, contractABI, privateKey, urlRPC, metadatas, ownerAddress)

```-->