Harmony: Deploy an HRC721 NFT on Harmony with IPFS

Learn how to deploy an HRC721 NFT on Harmony with IPFS.

What is Harmony?

Harmony is a blockchain network for decentralized applications that supports fully scalable architecture and secure random sharding. The Harmony network runs Thereum applications at a fraction of the gas fee price.

What is HRC721?

HRC721 is a token type that uses the ERC721 token standard but is deployed on the Harmony blockchain network.

Read below to learn how to deploy an HRC721 NFT on Harmony with IPFS.

Prerequisites:

1. We’ll start by uploading our images to Filebase for us to use.

To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.

2. Select ‘Buckets’ from the left side bar menu, or navigate to console.filebase.com/buckets.

Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.

3. Enter a bucket name and choose the IPFS storage network to create the bucket.

Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.

4. Next, select the bucket from your list of buckets, then select ‘Upload’ in the top right corner to upload your image files.

5. Select your images to be uploaded.

Once uploaded, they will be listed in the bucket.

6. You can view the object’s IPFS CID in the CID column, or you can click on your uploaded object to display the metadata for the object, which includes the IPFS CID.

Choose the method you prefer, and take note of the IPFS CID for each image you uploaded. We will reference this later.

7. Next, on your local machine, create a new file called NFTTokenBaseURL.json with the following content:

[
    {
      "id": 0,
      "description": "Filebase NFT",
      "external_url": "https://forum.openzeppelin.com/t/create-an-nft-and-deploy-to-a-public-testnet-using-truffle/2961",
      "image": "https://ipfs.filebase.io/ipfs/IPFS_CID",
      "name": "My Filebase NFT 0"
    },
    {
      "id": 1,
      "description": "Filebase NFT",
      "external_url": "https://forum.openzeppelin.com/t/create-an-nft-and-deploy-to-a-public-testnet-using-truffle/2961",
      "image": "https://ipfs.filebase.io/ipfs/IPFS_CID",
      "name": "My Filebase NFT 1"
    },
    {
      "id": 2,
      "description": "Filebase NFT",
      "external_url": "https://forum.openzeppelin.com/t/create-an-nft-and-deploy-to-a-public-testnet-using-truffle/2961",
      "image": "https://ipfs.filebase.io/ipfs/IPFS_CID",
      "name": "My Filebase NFT 2"
    }
  ]

Replace the names and descriptions to match your collection, and replace each IPFS_CID with the IPFS CID for each image you uploaded to Filebase.

8. Make another new file called NFTToken0.json with the following content:

{
    "id": 0,
    "description": "Filebase NFT",
    "external_url": "https://forum.openzeppelin.com/t/create-an-nft-and-deploy-to-a-public-testnet-using-truffle/2961",
    "image": "https://ipfs.filebase.io/ipfs/IPFS_CID",
    "name": "My Filebase NFT 0"
  }

This file holds the metadata for only Token0, whereas the first .json file held the metadata for all tokens.

Replace the names and descriptions to match your collection, and replace each IPFS_CID with the IPFS CID for the image that corresponds to your Token0.

9. Next, head back to your Filebase web console.

Upload both your NFTTokenBaseURL.json and NFTToken0.json files to your IPFS bucket. Take note of the IPFS CIDs for each of these files.

10. Next, we’ll use Remix Development Environment for deploying our smart contracts and minting our NFTs.

Navigate to the Remix IDE in your web browser.

11. Select the ‘Plugin Manager’ button on the bottom left.

12. Confirm that the ‘Solidity Compiler’ is set as ‘Active’.

If not, activate this plugin.

13. Create a new Remix workspace by selecting the plus sign button next to ‘Workspaces’:

14. Give your workspace a name:

15. Create the following directories in your new workspace:

16. Now we need a smart contract.

We’ll use ERC721PresetMinterPauserAutoId, which is a preset ERC721 contract. To use this contract, create a new file in the ‘contracts’ folder by selecting ‘Create New File’, then give the new file the name OpenZeppelinPresetContracts.sol

17. Enter the following content in this file:

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/presets/ERC721PresetMinterPauserAutoId.sol";

18. Next, select the Solidity Compiler on the left side bar menu.

19. Select the version of the compiler that matches the file’s specified compiler (in this case, 0.7.0), then select ‘Compile OpenZeppelinPresetContracts.sol’.

20. Once compiled, go back to the File Explorer screen.

You will see a variety of files that were imported during the compilation.

21. Next, select the ‘Deploy and Run Transactions’ tab on the left side bar menu.

22. Select the following configuration details:

  • Environment: JavaScript VM (London)

  • Gas Limit: 5000000

  • Contract: ERC721PresetMiunterPauserAutoID

Then select the drop down menu to the right of ‘Deploy’ to open the String Name, String Symbol, and Base URI fields.

Enter the following details:

Replace IPFS_CID with the IPFS CID of your Token0 NFT.

When finished, select ‘Transact’.

23. Once transacted, your transaction will be recorded:

24. Select the drop down menu to the right of your deployed contract’s name to reveal a variety of options for interacting with your NFT.

25. In the console output at the bottom of the Remix window, expand the details of your Transaction.

Copy your local wallet address, which is the ‘From’ value:

26. Head back to the Deployed Contracts interaction options, then in the ‘Mint’ field, enter your copied Wallet address inside quotation marks:

Then select the orange ‘mint’ button to mint. You can view the details of the minting transaction in the console output:

27. Now, let’s deploy onto the Harmony Testnet.

To do this, we need to configure our Metamask wallet to be on the Harmony Testnet, and we need some Testnet tokens from the Harmony Faucet.

View the Harmony Metamask configuration instructions here.

View the Harmony Faucet Information here.

28. In the Deploy and Run Transactions tab, change the Environment from JavaScriptVM (London) to Injected Web3

29. Metamask will confirm the wallet account you want to use.

30. Make sure the other configuration settings are the same as we configured before:

Replace IPFS_CID with the IPFS CID of your Token0 NFT.

Then select ‘Transact’.

31. Metamask will ask you to authorize and confirm the transaction:

32. The successful contract deployment will be shown on Metamask and in the Remix console output:

33. Then under ‘Transactions Recorded’, open the drop-down menu, and in the ‘mint’ field, input your Metamask Wallet Address in quotations, then select ‘mint’:

34. You will be prompted to authorize and confirm the transaction through Metamask again:

35. The successful transaction output will be listed in your Remix console:

Congratulations! You have successfully created an NFT on the Harmony Testnet!

If you have any questions, please join our Discord server, or send us an email at hello@filebase.com

Last updated