Navigate back to the homepage

NFT Minting Quickstart w/ Minty 🌿

Evan James Martin
August 2nd, 2021 · 3 min read

NFT Minting Quickstart w/ Minty 🌿

We’re going to mint an NFT in three steps:

  1. Generate a .jpeg
  2. Deploy a minting contract
  3. Execute the contract to mint
  4. (bonus) Pin our NFT to IPFS

I’ve adapted the tutorial: Mint an NFT with IPFS by ipfs.io.

We’re going to use some pre-built code to deploy a contract onto a locally running Ethereum network. Then we will execute that contract to mint an NFT and post a jpeg to IPFS.

Download Minty

Minty offers is an all-in-one solution for minting an NFT with IPFS (decentralized) file hosting.

First step is to download directly from the github repo

1$ git clone https://github.com/yusefnapora/minty ; cd minty

Install the NPM dependencies. Add the minty command to your $PATH.

1$ npm install ; npm link

Generate an NFT jpeg

Next, we need an image for our NFT.

random jpeg
CryptoPunks is the most popular generative project.

In the style CryptoPunks and other generative NFTs, we’re going to make a random jpeg and use it as our NFT image.

To generate a random jpeg I used an online tool to create a random 15x15 jpeg.

random jpeg
a random jpeg I generated using a onlinejpgtools.com

Save it in your minty/ directory. We’ll need it soon.

Run local Ethereum Blockchain

The Minty repo has a built-in script to run an Ethereum blockchain and local IPFS node.

1$ ./start-local-environment.sh

You should see:

1[eth] Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
2...
3[ipfs] Daemon is ready

If you do not, try running:

1$ nvm use 16

At this point, this is what you have running on your local machine:

local setup
The start-local-environment.sh script will spin up an Ethereum network and an IPFS node on local.

We’re ready to deploy a smart contract.

Deploy Minting Smart Contract

In order to create an NFT, we need to deploy the blueprint for creating the NFT.

In other words, we need to deploy the minting smart contract.

This smart contract (written in solidity) is included in the repo. We just need to deploy it.

In another terminal, run

1$ minty deploy

Aside: If you’ve worked with Serverless, you think of this as doing a serverless deploy . We are deploying the code that we want to eventually run.

Mint the NFT

Now that we have the local IPFS daemon, local Ethereum network, and smart contract deployed, minting an NFT is simple. We just specify what to tokenize, the name of the NFT, then add a description to tell users what the NFT is for.

1$ minty mint "./output-onlinejpgtools.jpg" --name "Random JPEG #1" --description "A randomly-colored 15x15 square."

Minty will mint the NFT and return some output:

minty mint output
The output message from Minty contains the addresses of your newly minted NFT.

That’s it! Minty executed your smart contract, and your smart contract created the NFT. Your jpeg was also uploaded to your local IPFS node.

pinata pin
Minty will execute the smart contract and will pin the jpeg to your local IPFS node.

If you have Brave installed you can view your NFT by pasting the Asset Address into the search bar. The reason this works is because Brave is integrated with IPFS.

brave displaying your IPFS resource
Brave is integrated with IPFS so it is able to display the jpeg asset hosted on your local IPFS node.

So you’ve created your NFT, but it’s only available to other people as long as you have your IPFS node running. If you shut down your computer or you lose your internet connection, then no one else will be able to view your NFT!

To get around this issue, you should pin the image to a pinning service.

Pin the .jpeg

The minty deploy command will deploy to a local IPFS node by default.

To use someone else’s node - one that is running 24/7, you can sign up for a pinning service such as Pinata.

You will need to grab an API key from Pinata. Your API key allows Minty to interact with your Pinata account automatically.

Log into Pinata and select API keys from the sidebar menu. Click New Key.

Expand the Pinning Services API drop-down and select all the options under Pins

api key creation
Create an API key for Minty to use by selecting all the options under Pins.

Pinata will give you an API key, and API secret, and a JWT.

1API Key: 43537d17e88805007086
2API Secret: 492b24f041b9120cbf8e35a247fb686793231a3d89045f1046a4f5b2d2175082
3JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiJiZDQ3NjM1Ny1lYWRhLTQ1ZDUtYTVmNS1mM2EwZjRmZGZmYmEiLCJlbWFpbCI6InRhaWxzbm93QHByb3Rvbm1haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInBpbl9wb2xpY3kiOnsicmVnaW9ucyI6W3siaWQiOiJGUkExIiwiZGVzaXJlZFJlcGxpY2F0aW9uQ291bnQiOjF9XSwidmVyc2lvbiI6MX0sIm1mYV9lbmFibGVkIjpmYWxzZX0sImF1dGhlbnRpY2F0aW9uVHlwZSI6InNjb3BlZEtleSIsInNjb3BlZEtleUtleSI6IjQzNTM3ZDE3ZTg4ODA1MDA3MDg2Iiwic2NvcGVkS2V5U2VjcmV0IjoiNDkyYjI0ZjA0MWI5MTIwY2JmOGUzNWEyNDdmYjY4Njc5MzIzMWEzZDg5MDQ1ZjEwNDZhNGY1YjJkMjE3NTA4MiIsImlhdCI6MTYxNjAxMzExNX0.xDV9-cPwDIQInuiB0M--XiJ8dQwwDYMch4gJbc6ogXs

Copy the existing config/pinata.example.env and replace the value for PINNING_SERVICE_KEY.

1$ cp config/pinata.env.example config/.env

Inside config/.env, add your JWT token to the PINNING_SERVICE_KEY line between the double quotes “.

1PINNING_SERVICE_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsia..."

Now you can use minty pin <token_id> to pin it to Pinata.

1$ minty pin 1
2> 🌿 Pinned all data for token id 1

You can then check your My Files page on Pinata.

…and if it’s there, your NFT jpeg is now pinned! This means that it will persist on IPFS even after you turn off your local IPFS node. Here’s the updated setup:

pinata pin
Minty will pin the jpeg to one of Pinata's IPFS nodes.

Pinata will store up to 1GB of NFT images/files for you for free. This image we just uploaded was 239 Bytes, so we have a lot of free space remaining if we wanted to mint some more.

But all done for now. 🏁

In this tutorial, we ran a local Ethereum network with a local IPFS node alongside it, deployed a smart contract to our Ethereum network, generated a random NFT jpeg image, and then used Minty to 1. execute the smart contract to mint the NFT and 2. to post the corresponding jpeg onto our IPFS node. As a bonus, we later pinned our NFT to the pinning service Pinata so that our NFT jpeg would be highly available.

More articles from EJM | Evan James Martin

EVM Portfolio Week 2

Side Chain Week 2: BNB v. AVAX v. MATIC v. FTM v. HT v. STAKE v. ONE

June 6th, 2021 · 1 min read

Buying into the Top EVM Blockchain Tokens

I bought $100 of each token from the top EVM chains

May 25th, 2021 · 5 min read
© 2021 EJM | Evan James Martin
Link to $https://twitter.com/evmartsLink to $https://github.com/evmartsLink to $https://instagram.com/ejm.devLink to $https://medium.com/@evmarts