Lazy Minting NFTs – The Full Guide

Non-fungible tokens, or NFTs, have become one of the hottest trends recently. This is not only the case within the blockchain industry – even mainstream media hangs on this latest crypto sensation. NFTs are digital assets with the potential to represent virtually anything from digital to physical assets. However, with the increased attentiveness towards NFTs and crypto in general, blockchain networks are experiencing trouble with scalability. This makes it economically unsustainable to mint NFTs as gas fees reach astronomical amounts. Therefore, to counteract this problem, the industry presents the concept of ”lazy minting”. This might be a concept unfamiliar to many, which is why we’re in this article going to delve deeper into lazy minting and the actual process of lazy minting NFTs. 

To begin with, we’ll start by taking a closer look at what NFTs are and what lazy minting entails. Following a description of the concepts, we’re going to take a look at the process of lazy minting NFTs. To demonstrate how lazy minting works, we’re going to create an NFT lazy minting dApp (decentralized application) with the help of the leading Web3 platform, Moralis. This process will be broken down into three steps, and the final product will allow us to continuously create NFTs without having to pay any gas fees! 

Nonetheless, let’s kick off this article by taking a closer look at what NFTs are and why they have gained substantial interest from people all over the globe. Also, looking to learn other useful tips and tricks regarding working with NFTs? If so, NFTCoders is for you! Start building dApps and NFT projects lightning-fast, and even learn how to build an NFT marketplace in just 5 easy steps! What are you waiting for?

What are NFTs? 

If you are somewhat familiar with the crypto industry, you’ve most likely heard of NFTs. However, even though you might be familiar with the word, it might still be a confusing concept. As such, we’ll dedicate this initial section to explaining what NFTs are, as this will help us clarify the lazy minting process.  

An initial clue to what NFTs are can be found in the name itself. ”NFTs” is an abbreviation for “non-fungible tokens”, and the keyword here is ”fungible”. Fungibility refers to the interchangeability of an asset. Further, it’s a standard economic term to describe resources of the same type and value. An example from the blockchain industry is Bitcoin, as all individual coins are the same, meaning that we can trade one for another.  

On the other side of the spectrum, we find “non-fungible”, which, therefore, refers to assets that aren’t interchangeable. An example of a traditional non-fungible asset is a house. All houses are unique, meaning it isn’t possible to swap one for another directly. As such, an NFT is a token that is unique and not replaceable.

Because these tokens are inherently non-fungible, they are ideal for representing assets with unique properties. Moreover, they are digital collectibles with the characteristics to represent either virtual or physical assets. 

However, an essential note-worthy factor is that NFTs only represent ownership of a unique item. If we take digital art as an example, the NFT doesn’t hold actual art but points to a specific art piece. This can be compared to a house deed. The deed itself doesn’t contain a house but specifies who owns the property.

What is Lazy Minting?

To understand what lazy minting is, an excellent place to start is the reason why it was needed to begin with. As more people adopt crypto, the blockchain networks are experiencing something known as congested networks. Congested networks refer to the enormous strain put on the networks due to their issues with scalability. This means that as more people get into blockchain and crypto, the networks fail to support a more significant number of transactions. 

Although mainstream adoption benefits the market, it negatively affects the current users as gas prices soar and it becomes economically unviable to make transactions. However, this hasn’t been an issue left in isolation as developers continuously set out to solve problems. A solution to this issue is lazy minting. Lazy minting provides developers and artists an opportunity to mint NFTs without paying any gas fees. So, how does this actually work? 

The definition of lazy minting is: ”…a way of minting an NFT without having to pay upfront gas fees.” To remove the initial gas fees and alleviate strain from the blockchain networks, lazy minting NFTs push the actual minting until the time of purchase. In turn, this allows for the creation of NFTs without the initial costs, as the substantial fees only have to be paid if someone purchases the tokens. This means that the minting responsibility transfers to the buyer of an NFT rather than the creator.

As we mentioned in the previous paragraph, this also partly deals with the issues of congested blockchain networks. It simply reduces the number of network transactions, which happens as computational power that’s only needed when NFTs are sold. As such, unsold NFTs won’t result in an unnecessary transaction. 

Lazy Minting NFTs – How to Lazy Mint NFTs

In this section of the article, we’ll break down the process of how to lazy mint NFTs. We’re about to create our very own lazy minting dApp that allows us to continuously develop new NFTs without having to pay any gas fees. 

We will be using Moralis in this example, as it’s is the fastest platform for NFT and dApp development. In fact, according to Polygon, Moralis cuts down the development time by a whopping 87%! 

The process of creating this dApp for lazy minting NFTs can be broken down into the following three steps: 

  1. Setting up a server.
  2. Structuring the application content with HTML.
  3. Adding the application logic.

Through this dApp, it becomes possible to repeatedly lazy mint NFTs by simply inputting a name, description, and an image. So, without further ado, let’s kick off this tutorial by creating our own Moralis server. 

Lazy Minting NFTs – Creating a Server

The first step in lazy minting NFTs is to create a Moralis server. To do so, you’ll need to be signed up with the platform. Setting up an account is easy, and once logged in, we can continue with the tutorial. 

With an account at hand, you’ll see the ”Servers” tab on the left of the admin panel. Once you navigate there, you can initiate the server’s setup process by clicking on ”+ Create a new Server” at the top right. 

Once you click this button, a drop-down menu with three alternatives will be presented to you. Your choice here should depend on where you would like to launch the dApp. For this tutorial, we are opting for a testnet server. However, once either alternative is chosen, you can continue by inputting the relevant information and hitting the ”Add Instance” button. 

With the server up and running, the next part of the first step revolves around installing a plugin. One of the reasons we have opted to work with Moralis is their Plugin Store. The store offers various plugins, one of which is the ”Rarible NFT Tool”.

You’ll find the plugin store by clicking on the ”Plugins” button for the server in question. All you need to do from there is to install the plugin and follow the instructions. However, one necessary element required to install the plugin is an Ethereum mainnet or testnet node. You can find a fully functioning node under the ”Speedy Nodes” tab on the admin panel. To acquire the node, you need to find the correct network, click on the ”Endpoints” button, and simply copy the URL. 

Lazy Minting NFTs – Structuring the Application Content with HTML

With our server at our disposal, the next step in the process is to structure the contents of our web application using HTML code. To begin with, you can go ahead and open your preferred development environment and create an ”index.html” file. You are free to design and structure your application according to your preferences; however, to make this tutorial even more straightforward, we’re going to utilize the Moralis vanilla boilerplate

After a few alterations to the boilerplate code, this is what the user interface might look like for the potential dApp: 

However, we won’t be going into any more detail regarding the code as this will vary depending on how you would like to structure and design your application. Nonetheless, for some additional inspiration and clarity, we’re going to link to the ”index.html” file from GitHub, which is related to the print screen from above. 

Lazy Minting NFTs – Adding the Application Logic

Now, with the proper structure for the contents of the dApp, we need to add some application logic. The reason for this is that we need to add functionality to the fields and buttons that we created in the previous step. We can initiate this by creating a ”main.js” file. In this file, we will implement three functions necessary to make sure that the application works. However, before this, we must also initiate Moralis, which can be done in the following manner: 

const serverUrl = “INSERT SERVER_URL”;
const appId = “INSERT APP_ID”;
Moralis.start({ serverUrl, appId });
let user = Moralis.User.current();

As you can see from the code above, we need to acquire a server URL and app ID. To fetch this information, you simply need to navigate back to the admin panel, click on the ”Servers” tab and get the information by pressing the ”View Details” button for the server in question. You can then copy and paste this information into your code. 

Now, with the instance initiated, we can move on to the first function of the dApp, which allows users to authenticate themselves and log in with MetaMask

First Function – ”login()”

The ”login()” function first of all checks if there is a current MetaMask user already authenticated. If not, then the code calls the ”authenticate()” and ”initApp()” functions. What this does is allow users to authenticate themselves with MetaMask if they haven’t already. This is a pretty straightforward function that looks like this: 

async function login() {
  if (!user) {
   try {
      user = await Moralis.authenticate({ signingMessage: "Hello World!" })
   } catch(error) {

Second Function – ”initApp()”

The second function of ”main.js” is called ”initApp()”, and this function does two things. First, the function displays the interface to the dApp’s users. Second, it also adds the ability to click on the ”Submit” button, allowing users to submit the necessary information needed to lazy mint an NFT. This is the full function: 

function initApp(){
    document.querySelector("#app").style.display = "block";
    document.querySelector("#submit_button").onclick = submit;

Third Function – ”submit()”

The third function of the dApp is ”submit()”, the most extensive function of the bunch. This takes care of the logic behind the lazy minting process. We’ll divide the function into smaller parts and explain them individually, starting with the initial section:

async function submit(){
  const input = document.querySelector('#input_image');
  let data = input.files[0]
  const imageFile = new Moralis.File(, data)
  await imageFile.saveIPFS();
  let imageHash = imageFile.hash();

In this part of the function, we fetch the image data that the users of our dApp upload. The image data is then uploaded to IPFS, which is possible through a single line of code as we are utilizing Moralis. Once uploaded to IPFS, we acquire the image hash and save it into a variable. That covers the first part; let’s take a closer look at the preceding code: 

<code>let metadata = {
    name: document.querySelector('#input_name').value,
    description: document.querySelector('#input_description').value,
    image: "/ipfs/" + imageHash
  const jsonFile = new Moralis.File("metadata.json", {base64 : btoa(JSON.stringify(metadata))});
  await jsonFile.saveIPFS();

In this part, we begin by creating a metadata object using the name, description, and image hash. We continue by stringifying the data to JSON format and, once again, uploading this to IPFS. Now, with the metadata object uploaded to IPFS, we can move on to the third part of the ”submit()” function: 

let metadataHash = jsonFile.hash();
  let res = await Moralis.Plugins.rarible.lazyMint({
    chain: 'rinkeby',
    userAddress: user.get('ethAddress'),
    tokenType: 'ERC721',
    tokenUri: 'ipfs://' + metadataHash,
    royaltiesAmount: 5, // 0.05% royalty. Optional

We continue by fetching the JSON file’s hash. This is then used when calling the ”Moralis.Plugins.rarible.lazyMint()” function. Moreover, we also include some additional information and pass this as an argument when calling the function. However, some of this info can be changed depending on the specifications of your project. Finally, to top everything off, this is the fourth part of the function: 

  document.querySelector('#success_message').innerHTML = 
    `NFT minted. <a href="${}:${}">View NFT`;
  document.querySelector('#success_message').style.display = "block";
  setTimeout(() => {
    document.querySelector('#success_message').style.display = "none";
  }, 5000)

This simply displays a success message and a link to the NFT so that the users have easy access to their creation. Now, that’s it for this simple application that allows users to continuously lazy mint NFTs. If questions remain regarding the application logic, you’ll find the complete file at the “main.js” page on GitHub. Moreover, for a complete overview of the dApp code, you can also visit the GitHub page

Lazy Minting NFTs – Conclusion

NFTs are one of the hottest topics within the blockchain industry, and it partly has to do with the uniqueness that characterizes these tokens. People are paying astronomical amounts for NFTs, and it is positively benefiting developers and artists all over the globe. However, with the increased adoption, networks are getting congested, resulting in high transaction costs. This negatively benefits the creators of NFTs as it becomes economically unviable to mint new tokens. 

However, to solve this, a concept known as lazy minting was introduced. Lazy minting allows developers and artists to create NFTs without an initial gas fee. Instead, the actual minting process is postponed to the time of purchase. As such, the minting responsibility befalls the buyers and not the creators of NFTs. 

This article quickly demonstrated how you can lazy mint NFTs by creating a simple dApp. To facilitate this, we decided to utilize Moralis, the biggest Web3 dev platform, as this significantly cut down the development time of our dApp. As a result, we created a lazy minting dApp that allows us to continuously create NFTs without paying any initial gas fees in just minutes. 

If you have further interest in NFTs, then be sure to check out our other articles here at NFTCoders to get the greatest and latest tips on NFT development!

January 13, 2022
Become a Moralis Mage
Get the latest information about Moralis Web3 in your email
Get Loved BY
the Web3 community

Related Articles