Minting your own NFT ERC721 collectible art for less than $0.01

Jeff P
11 min readMar 28, 2021

NFT’s seem to be all the rage right now, but if you’re a casual investor or a creator of art, you might not understand the process of creating your own NFT crypto tokens, and even if you do know how to mint the NFT tokens, you might be put off by the excessive gas fees to mint them on the Ethereum blockchain.

Well don’t worry, I’ll talk you through exactly how to mint your own fully-compliant ERC721 NFT token asset that represents your digital art, and it will cost you less than $0.01 to do so.

Once minted, you can transfer your NFT asset to others, sell it, and basically do whatever you want with it.

What you’ll need

  1. A free HPB blockchain wallet — You can obtain this a number of ways. You can download the HPB Wallet from the AppStore.

Another option for a wallet — Because the HPB blockchain network is fully Ethereum compliant, you can actually just use an Ethereum wallet, and open it in Metamask, and then switch networks to HPB.

In fact, you can even grab an instant HPB wallet by heading to Telegram, and then starting a conversation with the “HPB Tip Bot” (@HPBTipBot) telegram , and then use the /deposit command to view your HPB wallet address, and the /export command to view your private key.

2. You’ll need Metamask — You you can use either the Chrome or the Edge extension version on your PC

3. You’ll need a teeny-weeny tiny amount of HPB in your wallet to cover the fractional gas fee. I’m talking literally $0.01 worth of HPB coin to cover the NFT mint. You could obtain HPB for your wallet by either purchasing some HPB from the Kucoin exchange (There’s also Bibox, Gate.io, MXC, Indodax exchanges), or if you are really nice and extra charming to the “HPB Price” Telegram community members, they may even tip you a small amount of free HPB to your wallet :)

4. You’ll need to open a free account with pinata.cloud — This is what will allow you to upload your unique artwork which will generate a “hash” of your artwork

5. You’ll need a text editor (notepad, notepad++ or anything similar is fine)

6. You’ll need access to remix.ethereum.org to allow you to deploy your NFT smart contract

7. You’ll need a copy of the actual NFT smart contract code to deploy (available further down this guide) as well as a .json file that will store the metadata associated with the artwork (A template json file is also provided further down this guide)

8. Last but not least, you’ll need some original artwork! :)

Ok, let’s get started!

Get yourself ready for the HPB network in Metamask

You’ll need Metamask to mint your NFT token, and to be able to mint the token cheaply ($0.01!) you’ll need to be connected to the HPB blockchain network with Metamask.

Once you’ve setup and ran Metamask, you’ll want to head into “Settings” -> “Network”, and point to the “CUSTOM” network of HPB. You’ll need the following information:

Once you’ve saved that, you’ll be connected to the HPB network. Now like I say, you’ll need a tiny bit of HPB in your account, and it’s up to you how/where you get it, but once you have some funds in your Metamask wallet, and you are pointing to the HPB network, you’re ready for the next step.

Upload your artwork to Pinata.Cloud

Login to pinata, and click to upload a new pin:

Select the artwork you wish to mint as an NFT and upload it.

Once you’ve done that, you’ll see an IPFS CID hash. This hash represents the artwork. Only that exact artwork will generate that hash. If you changed a single thing about the artwork, you’d get a different hash.

Ok so now you have that hash, you’ll need to add it to a .json file which will be used as the artworks Metadata, and will allow NFT websites to pull information about your artwork when it’s displayed on their site.

To create a .json file for your metadata, simply open up your text editor, and use the following syntax for your file: (You can copy this, including the opening and closing curly braces to act as a template)

{
“hash”: “QmaWMJW4sNF9wwskie9j4cEUaS7YCqY7NyHRffQnU7mxku”,
“blockchain”:”HPB”,
“token_type”:”HRC721",
“blockchain_url”:”https://hpb.io",
“Artwork Creator”:”Me!”,
“URL”:”https://waxlyrical.medium.com",
“Info1”:”some info”,
“Info2”:”some more info”
“Info3”:”even more info”,
“Info 4”:”hopefully you get the point"
}

A couple of quick things to point out. Firstly, the .json has a series of data pairs. They are basically objects and then the associated attributes for the objects. You can include as few or as many objects and attributes as you want, but the important one is the very first one, the hash and it’s value
the value for hash.

This will be the “IPFS CID Hash” that you would’ve generated when you uploaded your artwork to pinata.

So for example, you could copy the entire .json file in the example above, and paste it into a basic text editor such as notepad or notepad++
You then edit the objects and attributes to whatever you want them to be.
It’s very important to note the formatting and syntax.

  • Each object is enclosed in “ “
  • Each attribute is also enclosed in “ “
  • The objects and attributes are separated with a colon :
  • Each value pair ends with a comma (,) EXCEPT for the final value pair which doesn’t have a comma. Don’t forget this bit!
  • The file must begin with an open curly brace {
  • The file must end with a closing curly brace }
  • Remember to add your pinata IPFS CID hash as the hash attribute!

Once you’ve completed your .json file, save it as anything you want, but it must be saved as a .json file. Depending on the text edit your are using, you may need to override the default filetype it will try to save as (often this will be .txt)

Upload your .json file to pinata

The next step is to once again upload the .json file you just created to pinata. You will now receive a second hash. This second hash, which is the hash of your metadata for your artwork, including the hash of the artwork itself, is what we will “mint” to your NFT token, which will be forever stored on the blockchain!

Once you’ve got that second IPFS CID hash, you are now ready to switch to remix.

Head over to https://remix.ethereum.org

When you first load up Remix, you’ll probably see a bung of dummy example smart contracts in the workspace column on the left. You don’t need any of those, so click on them, then use the “bin” icon to delete them. Once your workspace is completely empty of unnecessary files, click on the new file button and name your new file “nft.sol”

You should then be presented with a blank page ready to add your smart contract code:

The next thing we want to do is actually add the smart contract code to the blank page. Now I won’t have time to teach you solidity programming in this post (there are plenty of great free resources out there to learn solidity programming!) but suffice to say, the code below is what you’ll need to mint your NFT token:

once you copy/paste the code into the page, it should hopefully look like this:

Before we move on, there’s a couple of lines of code that I’ll need to draw your attention to for editing…

Line 5 says:

contract HPBWaifu is ERC721, Ownable

I named my smart contract “HPBWaifu” as I was minting Waifu cards as NFT’s. You should change your contract name to something more appropriate. Note that the contract name cannot contain spaces, hence the reason why I called mine “HPBWaifu” as opposed to “HPB Waifu”

Line 9 says:

constructor() ERC721(“NFT-HPB”, “WAIFU”) {}

I have declared my constructor as “WAIFU” as this is representative of what I’ll be minting. Your own declaration can be anything you want, but I’d recommend that it’s something related to what you are minting. It should also be different to the contract name. Again, no spaces!

Ok that’s the smart contract ready, the next thing to do is point Remix to the HPB network:

Firstly, switch to the “compile” tab, and ensure “Auto Compile” and “Enable Optimization” are both ticked. The program should then start to compile.

If it doesn’t you may need to switch to http:// connection to get it to compile. If remix hangs when it compiles this is usually the problem, and it will give you a warning at the bottom of the scree that you are attempting to use https:// in a web3 environment, so change the https:// in the url bar to http:// if it hangs.

If all goes well, and the program compiles, you’ll see some extra options in the bottom left.

Now we can switch to the “Deploy” tab. You should firstly switch your “Environment” to Injected Web3

At this point, you may be prompted by Metamask to confirm that you wish to connect it to the remix environment, ready to pay the gas fee to mint the NFT token.

Once you have connected Metamask, you are now ready to mint your token!

From the “Contract” drop-down menu, select the correct smart contract that you wish to deploy. In my case it would be HPBWaifu — nft.sol

Now click deploy, and Metamask will prompt you to make the transaction to mint the token with a small gas fee.

As you can see, it’s going to cost me 0.03 HPB to mint my token. The current price of 1 HPB is around $0.34 per coin, so 0.03 x $0.34 = $0.0102 — Basically 1 cent to mint the token :-)

Once you’ve confirmed, and minted the token, you’ll see details of the smart contract on the left column:

Those orange buttons in the smart contract drop-down menu represent “write” functions, where you can interact with the NFT smart contract.

If you scroll down further, you’ll see blue buttons. There represent “read” functions, where you can read data that’s stored on the smart contract.

Now with any type of Ethereum compatible smart contract, “write” functions cost gas because you are writing to the smart contract on the blockchain, and the “read” functions are free as you are simply viewing information stored.

So with this special NFT ERC721 token, part of the smart contract logic, is that you can only “write” to the “mint NFT” function in the contract ONCE….and only ONCE. As soon as you write to this function, the token is fully NFT compliant and minted, and cannot be changed. Scroll through the orange buttons until you reach the “mintNFT” function, and open it up. You’ll see two fields:

  • receiver
  • tokenURI

The receiver field is where you put the wallet address of the NFT token holder. If you want the token to go to yourself, then put your own HPB wallet address in this box. To get the HPB wallet address, you can simply copy it from Metamask

the second field (token URI) is the hash data you will be writing to the token, so that the data is forever paired to the NFT token. In this box is where you want to paste in the IPFS CID hash of the .json metadata file you uploaded to pinanta.

Once you’ve filled out both boxes, click on the “transact” button, and once again, Metamask will prompt you to pay the gas fee to “write” the information to the smart contract. This process costs even less than the minting cost….far less than 1 cent :-)

As soon as that is processed, the NFT is fully minted and compliant. Congratulations, you have just minted your own NFT token art with a tokenID value of 1 (you can mint more than one with this smart contract, for example a set of rare collector art, with this being #1 of 20!)

You can verify what has been written to the contract with the blue “read” buttons.

If you wanted to sell or transfer your newly minted NFT token, you can use the “safeTransferFrom” write function:

you add the owners wallet address in the “from” field, the new recipients wallet in the “to” field, and the token ID will be 1, unless you mint more NFT’s.

If you do want to mint more, once again follow the steps of uploading the artwork to pinata and then taking the hash of the artwork, copying it into a new .json file, then uploading that json file, and then using the hash of that .json file with the “mintNFT” function, and the tokenID index will increment by one, each time you do it.

I may follow this up with another write up where you could potentially add randomly generated attributes to NFT cards using the HPB Hardware Random Number Generator (HRNG) for things like “Top Trumps” style cards.

--

--

Jeff P

I tend to write about anything I find interesting. There’s not much more to it than that really :-)