Skip to content

chainstacklabs/javascript-programmatic-nft-minter

Repository files navigation

Labs

Chainstack is the leading suite of services connecting developers with Web3 infrastructure

         

Supported protocolsChainstack blogChainstack docsBlockchain API referenceStart for free

NFT Minter Tutorial

This project contains all of the tutorial files from The ultimate guide to NFTs: From concept to market success published on the Chainstack blog.

Project details

This repository contains scripts and contracts needed to create a new wallet, check its balance, compile an NFT contract, and mint NFTs using custom metadata on the Ethereum network.

Find the full tutorial article available on the Chainstack blog:

Quick start

Clone this repository.

Install dependencies

npm ci

Use npm ci to launch a clean install of the dependencies, this will install the same version as in the package.json file.

Edit .env.sample

Edit the .env.sample file, fill up the fields, and rename it to .env.

ENDPOINT_URL = "https://YOUR_CHAINSTACK_ENDPOINT_HERE" 
PUBLIC_KEY = "0x_YOUR_WALLET_ADDRESS" 
PRIVATE_KEY = "YOUR_PRIVATE_KEY" 

Fill the CONTRACT_KEY field once you deployed the smart contract.

Compile the smart contract

Go into the contracts directory:

cd contracts

Compile the smart contract with the solc compiler:

solcjs --abi --bin  --include-path ../ --base-path . -o compiled PCHNFT.sol

Now you will find the compiled smart contracts' bytecode and ABIs in the compiled directory.

Deploy the smart contract

At this point, you can deploy the smart contract using the deploy.js script in the scripts directory.

Go into the scripts folder and run:

node deploy

You just deployed your NFT smart contract. See the The ultimate guide to NFTs: From concept to market success to mint your NFTs.

Prerequisites

The system requires at least:

  • Node.js: ^16.17.0— install Node
  • Solc.js installed globally

Dependencies

  • web3.js: ^1.7.5
  • @openzeppelin/contracts: ^4.7.2
  • Solc.js: ^0.8.17
  • dotenv: ^16.0.1
  • fs: ^0.0.1-security

Install

Clone this repository

git clone https://github.com/soos3d/NFT-Minter-Tutorial.git

Install dependencies

npm ci

Use npm ci to launch a clean install of the dependencies, this will install the same version as in the package.json file.

Install solc globally

npm install -g solc

Examples

The following list shows how the end result looks like: