Simple NFT mint example using Metaplex

Simple script that runs on devnet and:

  1. Uploads image to IPFS using Pinata
  2. Uploads metadata to IPFS using Pinata
  3. Mints NFT using @metaplex/js

Usage

Install dependencies:

yarn

You’ll need Pinata secrets to upload to Pinata. Create an account and generate API keys.

Add the following environment variables to your .env file:

API_KEY=<Your API key>
API_SECRET=<Your API secret>

Run:

yarn start

Example output:

Image URL:  https://gateway.pinata.cloud/ipfs/QmZD7yDhMYPYbviUBi1SbxeoqcSpLdhaHbewuAJ7z9xFuj
Metadata URL:  https://gateway.pinata.cloud/ipfs/QmVrRwghWqmUMo3HPQ5rMftS3CuWPjjMbJStHoJx3Zde91
Solscan URL:  https://explorer.solana.com/address/5sgmdQpNr2M1wzkTedGfB3GtbtDL6LFonYFJ2ZjnFfiV?cluster=devnet

Source

upload.js

  • Handles the uploading of image and metadata
  • image url is hardcoded from the asset folder

mint.js

  • Handles minting of NFT with given metadata

utils.js

  • Creates and returns simple metadata for NFT

index.js

  • Handles key creation. Orchestrates NFT creation.

Resources and Links

GitHub

View Github