Skip to content

lastrust/boilerplate-for-nft

Repository files navigation

Boilerplate for NFT Minting Application

This boilerplate is for NFT Minting applications. Using this boiler plate, a minting site can be created in about 30 minutes.

image

Getting started

I will now show you how to use this boilerplate.

Demo application is here

Need help? Ask in our discord.

1. Store metadata for NFTs

Get an overview

First, metadata and images for NFT must be stored in storage.

For example, if you wish to issue 30 NFTs, create directories and files like the following.

  • images
    • 0.png
    • 1.png
    • 2.png
    • ...
    • 29.png
  • json
    • 0.json
    • 1.json
    • 2.json
    • ...
    • 29.json

The JSON file looks like this.

Since the image field requires the URI of the image to be entered, the first step is to save the images somewhere and then enter the URI in the JSON.

0.json:

{
  "name": "Bunzz #0",
  "description": "Bunzz NFT",
  "image": "<URI for image>",
  "edition": 0,
  "date": 1664941479203,
  "attributes": [
    {
      "trait_type": "Background",
      "value": "Black"
    },
    {
      "trait_type": "Bottom lid",
      "value": "High"
    },
    {
      "trait_type": "Top lid",
      "value": "Middle"
    }
  ],
}

Download hashlips

These JSON and images can be created manually, but there is a useful tool called hashlips that can be used to create generative NFT.

The basic generative NFT is created by creating multiple images, one for each layer of background color, hat, etc., and combining them. hashlips is a tool that makes it easy to do this.

https://github.com/HashLips/hashlips_art_engine

We will use this repository, so download it.

$ git clone https://github.com/HashLips/hashlips_art_engine

Go to the hashlips directory and install the dependencies.

Note: Use node version 14.18.x.

$ yarn install

Check directory structure

By default, there are these layers, each containing images in its own directory. The generative NFT overlaps one image from each layer to produce a single image.

スクリーンショット 2022-10-11 11 10 57

For use in a production environment, try replacing these images to create your own generative art.

If you replace it, please also change the following part of config.json.

スクリーンショット 2022-10-11 11 16 07

Determine the number of images

Determines the number of images to be generated. Set the value growSizeEditionTo in config.json to any value you like. This time, we will set the number to 30.

スクリーンショット 2022-10-11 11 16 07

In addition, change line 343 in main.js as follows.

- let i = network == NETWORK.sol ? 0 : 1;
+ let i = 0;

This is because the NFT contract used in this project has a token ID that starts with 0, so the file name is also set to start with 0.

Make images and json

Now let's create the image and JSON files.

$ node index.js

The deliverables are contained in the build directory.

スクリーンショット 2022-10-11 11 34 28

Uploading images data to IPFS

First, upload the image files to IPFS. You can use a service called Pinata.

https://app.pinata.cloud/pinmanager

Select the folder upload.

スクリーンショット 2022-10-11 11 36 58

Upload the build/images you just created.

スクリーンショット 2022-10-11 11 38 16

Enter any name you like. When you are done, click Upload.

スクリーンショット 2022-10-11 11 39 38

Once the upload is complete, you will see the following row.

スクリーンショット 2022-10-11 11 45 25

Upload JSON files

As introduced in first section, the URI of the image must be entered in the image field of the JSON file.

Paste the CID from earlier after ipfs:// in the baseUri of config.js

スクリーンショット 2022-10-11 11 52 41

Then execute the command.

$ node utils/update_info.js

The contents of build/json will then be rewritten so that the image field of each JSON file points to the uploaded image.

スクリーンショット 2022-10-11 11 55 46

Now upload the build/json directory to IPFS in the same way as for build/images.

2. Deploy smart contract

Having uploaded the JSON and image files to storage, the next step is to prepare the smart contract.

Create DApp

Please access to Bunzz.

Once accessed, connect to the wallet.

スクリーンショット 2022-10-11 16 17 49

Once connected, make sure you have enough MATIC. If you do not have enough MATIC, you can get it here.

Then click on "Create Dapp".

スクリーンショット 2022-10-11 12 00 44

Next, enter a name.

スクリーンショット 2022-10-11 12 03 23

Next, select the chain. Here we will use Mumbai Testnet.

スクリーンショット 2022-10-11 12 04 16

Then go to the All tab and type "leadedge".

スクリーンショット 2022-10-11 12 05 57

Then click on "Add+". And click "Continue".

スクリーンショット 2022-10-11 12 08 00

Finally, enter the arguments for the contract.

スクリーンショット 2022-10-11 14 04 09

argument name description
name_ Contract Name(displayed as Collection Name at Marketplaces) test
symbol_ Symbol of a token (NFT), like USD or YEN. For example, BAYC, AZUKI, etc. TEST
baseTokenURI_ IPFS can also be used for the baseTokenURI. For example, Pinata is easy to use ipfs://QmZtTG47eDgLLdMzuuQSCwJ4YKEuNRNv6hZ5tD82ah6Fyb/
maxSupply_ Maximum number of NFTs that can be minted. Set the quantity that can be sold out. 30
preCost_ Mint cost when presale (= only WL users can mint) 30000000000000000
publicCost_ Mint cost when public sale 30000000000000000
maxMintableQuantityPerWL_ Mintable quantity per WL slot(=WL user) 3
mintableLimitPerTX_ Upper limit of mintable in one tx. bot prevention 3

When you are finished, click Deploy.

Dapp will then be created and a modal for deploying the module will appear.

Click "Confirm" to deploy.

スクリーンショット 2022-10-11 14 15 17

Deployment is complete.

スクリーンショット 2022-10-11 14 18 55

This contract also includes an NFT sales feature for whitelisting, but we will not be using that feature in this case, so we will turn that feature off.

The documentation details how to turn off that feature.

  1. After a presale, start a public sale duration by calling the setPresale and the pause

Now close the modal and click on the down arrow button to the right of the module name.

スクリーンショット 2022-10-11 14 33 43

Then the list of functions of the contract will be displayed, and you can actually interact with the contract.

スクリーンショット 2022-10-11 14 35 12

Call the setPresale and pause functions to stop the white list sales function.

スクリーンショット 2022-10-11 14 38 57

スクリーンショット 2022-10-11 14 39 25

3. Prepare App

The final step is to build a front-end application that communicates with the smart contract.

Download boilerplate

Please download the this boilerplate first.

$ git clone https://github.com/lastrust/boilerplate-for-nft.git
$ yarn install

Setup variables

Please create .env file in root directory of the project (boilerplate-for-nft/.env).

The method of obtaining each value will now be explained.

REACT_APP_CONTRACT_ADDRESS=<your contract address>

If you are using something other than Mumbai Testnet, change the following constants as needed in file src/const/networkInfo.

Start application

When you are ready, launch your application.

$ yarn start

Test

When you start up the application, you will see a screen like this.

Please click "Connect" button. And test mint.

スクリーンショット 2022-10-11 15 49 42

If successful, the minted NFT is displayed as follows.

スクリーンショット 2022-10-11 16 14 00

This is an introduction to the use of this module🎉 Thank you.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •