Search
Generic filters
Share on facebook
Share on twitter
Share on linkedin

How to Mint NFTs for Free Without Paying Gas Fees

As most developers and NFT artists know by now, minting NFTs are by no means cheap. In fact, gas fees on Ethereum keep increasing as the network gets congested. In turn, NFT creators many times see the process to mint their NFTs as non-profitable. However, programmers have found a way in which one can bypass the process of paying for gas fees. Moreover, as a pioneer in blockchain projects, Moralis has found a solution that lets developers implement a single line of code that enables creators to mint their tokens without paying these exorbitant fees. As such, to mint NFTs for free without paying gas fees is all possible through Moralis’ Rarible plugin, which we’ll explore in this article.

Usually, when you want to mint NFTs, you need to complete a few steps. In many cases, these are drawn-out steps that are cumbersome to finish. Additionally, in some cases, you’re required to write a smart contract. Then, whenever you sell your NFT, a percentage of the money goes as commission to the marketplace. However, thanks to the fantastic platform created by Moralis, you neither need to spend gas fees nor have to write smart contracts. By utilizing short lines of code and using the Rarible plugin provided by Moralis, you can mint NFTs for free using a concept known as “lazy minting”. Before going further into the main topic of this article, we would like to explain some commonly used terms and phrases to you. That way, you’ll have a better foundation in which you can continue to learn how to mint NFTs for free without having to pay gas fees. 

Mint NFTs Without Paying Gas Fees – NFTs and Minting Explained

The popularity of non-fungible tokens is increasing daily, and NFTs transaction volume keeps setting new records. Just in the third quarter of 2021, the NFT market generated $10.67 billion, which is more than a 700% increase compared to the previous quarter. In the digital world, non-fungible tokens, commonly known as NFTs, are unique assets that you can buy and sell, just like physical properties. These pieces of data are not interchangeable, meaning that they have no tangible form of their own. In other words, you can consider these blockchain-based tokens as proof of ownership for assets and goods. Moreover, an image, GIF, video, or even a piece of music are all examples of NFTs. Additionally, NFTs can also represent physical assets. Currently, various blockchains support NFTs, including Ethereum, BSC, Trone, EOS, etc., with Ethereum as the most popular one.

However, what does it mean to mint NFTs, and why should you normally pay to “mint”? Here, mint or minting refers to the procedures for changing digital files into assets on various blockchains such as Ethereum. By minting NFTs, you store tokens on digital ledgers forever in a way that nobody can edit or delete them. In this way, NFTs become part of the blockchain, and you put them into circulation like real coins. Moreover, NFT owners can determine royalties for them as well. This means that whenever the buyer sells an NFT, the original owner will receive a commission. A common process to mint an NFT is to download an Ethereum wallet (such as MetaMask) and then upload your digital content into a marketplace to mint it. With this method, you could not mint NFTs for free, and you would have to pay for it! However, follow along to learn how to skip this costly process.

Mint NFTs Without Paying Gas Fees – What is an NFT Marketplace?

Most transactions concerning NFTs happen on an NFT marketplace, which is the equivalent of eBay or Amazon but for non-fungible tokens. There are more than dozens of NFT marketplaces out there, with OpenSea and Rarible as the most popular ones. As stated earlier, you must obtain ETH (Ethereum’s native cryptocurrency that fluctuates continuously) for minting NFTs. On Rarible, costs are slightly higher, and it charges both parties a service fee of 2.5% per sale. However, the seller can pay the entire cost equal to 5% of the final price.

Moralis is a reference for hosting, uploading, and automating dApps that lets you mint NFTs without paying gas fees via its Rarible plugin. The process of minting an NFT without paying for gas is also known as “lazy minting”. We’ll touch briefly on this topic further down in this article. 

Mint NFTs Without Paying Gas Fees – Getting Started!

Moreover, just follow the steps below to mint NFTs for free. As such, you’ll need a Moralis account, Moralis server, text editor, Moralis’ boilerplate, crypto wallet (preferably MetaMask), and install Moralis’ Rarible plugin. As stated earlier, you can set royalties for your NFTs with ERC-721 and ERC-1155 token standards.

Follow along with the below steps to mint NFTs without paying any fees:

  • Sign up for a free Moralis account and create a Moralis server.
  • Download your code editor of choice (such as Atom or Visual Studio Code [VSC]).
  • Use Moralis’ boilerplate on GitHub.
  • Download MetaMask.
  • Install Moralis’ Rarible plugin.

Please note that much of the code snippets presented in the following subsections are already implemented in Moralis’ boilerplate on GitHub.

Create a Moralis Account and Create a Moralis Server

To add the minting functionality of NFTs to your dApps, you need a server URL and application ID from Moralis. To obtain these, just go to Moralis and create your account for free. After signing in to your account, you have to create a new server. To do so, just click on the green button (“+ Create a new Server”) in the top-right corner of your screen and select the mainnet server. In the “My Moralis Instant” field, input your desired name for the server. Then, set your region and choose the blockchain of your choice. Once done, start your server by clicking on “Add Instance”. Moreover, it will take some time for the server to spin up, so please be patient. Once the server is running, click on the view details button and then copy the server URL and application ID. Then, paste them into your “main.js” file.

const serverUrl = “INSERT SERVER_URL”;
const appId = “INSERT APP_ID”;

Remember, you do not need a webserver to open your file. Instead, you can either run a webserver from Python in your terminal or download the “Live Server” plugin from VSC.

Utilize Your Preferred Code Editor

Now, open your editor of choice. Depending on your OS, you can use Atom, Visual Studio Code, Oxygen, etc. Moreover, by right-clicking in your directory on the left-hand side, add two files: an “index.html” and a “main.js” file. Then, go to the Moralis GitHub page to get the boilerplate (reusable code snippets). Just copy the HTML and JavaScript code and paste them into the affiliated files in the editor. The boilerplate will help you to create a workable UI and the required functionality for minting NFTs. In the end, you can integrate the functionality into your dApps. Watch the tutorial video on our YouTube channel to learn how to tweak the HTML and JavaScript code.  

Download Moralis’ Boilerplate from GitHub

If you’d like to create a dApp in a simple way, you could utilize our boilerplate as a shortcut. This boilerplate contains all the necessary code for a starter NFT minter dApp. As such, you can fetch the necessary files and the complete code and then import it into your code editor. To do so, please see our GitHub page. Since the boilerplate contains some useless functionalities and elements, you can go ahead and delete those.

Download MetaMask and Implement Crypto Login

As stated earlier, you’ll need a crypto wallet to authenticate users in your dApps and prove NFTs’ ownership.

To enable your dApps users to authenticate with MetaMask, you need to implement the necessary code provided in Moralis’ documentation. Here is what part of the code looks like:

Moralis.authenticate().then(function (user) {
    console.log(user.get('ethAddress'))
})

This will connect to MetaMask and request a signature (no gas required!). For a more detailed explanation of how to implement MetaMask authentication, please see our documentation.

Using the Moralis API to Mint NFTs Without Paying Gas Fees

Moralis’ API lets you get detailed information about your users (such as token and NFT balances, NFT ownership, the transaction history, etc.). This API from Moralis is highly beneficial as it lets you implement specific functionalities into your dApp. For instance, you can implement a DEX to your dApp, which would set your dApp apart from the competition. 

Moreover, to add style to your HTML file, you can go to the MDBootstrap library and fetch a neat CSS file. Then, copy the CSS file and paste it into the head element in your HTML code. 

Installation via CDN is probably the easiest way to implement a kit from Bootstrap. For more information on how to do so, check out MDBootstrap.com’s explanation.

Install Moralis’ Rarible Plugin

After fine-tuning the UI of your dApp and toggling with the JavaScript functionalities, install Moralis’ Rarible plugin. As such, it will make it possible to securely create, sell or collect digital items. Moreover, Moralis’ Rarible plugin lets you lazy mint NFTs, meaning that you can mint NFTs without paying gas fees. In this method, only the first buyer of the NFTs has to pay the gas fee. Typically, to mint NFTs, you have to pay for creating smart contracts and NFTs through gas fees. However, by using Moralis’ Rarible plugin, you would mint NFTs for free.

To get the plugin, head over to Moralis.io/plugins and click on the “Rarible NFT Tools” plugin followed by “Install the plugin”. Then, the administrative interface of your account in Moralis will open. Choose your server in the pop-up window (as illustrated above) and click on the confirm button. Then, a configuration page for the Rarible plugin will open. Here, you should add the Moralis Speedy Nodes endpoints information for the mainnet and Rinkeby networks (this might be different depending on which network you choose when starting your server). However, there is an update on the way, and soon, you’ll not need to copy and paste the Moralis Speedy Nodes information manually. 

Mint NFT Without Paying Gas Fees – Building the Logic

Now it is time to add some logic. We have to add the functionality of uploading images to our web page by tweaking the “main.js” file. To add this functionality, we need to add a “submit()” function. However, the following code snippet is just a simplified explanation. Therefore, we advise to check our NFT minter programming tutorial video on YouTube explaining how to implement, tweak and add more lines to the following code:

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

Next, you’ll have both the IPFS URL and its cryptographic hash whenever you upload an image. IPFS, which stands for “InterPlanetary File System”, is a peer-to-peer network for storing and sharing data on a distributed file system. If you have the “Brave browser” on your computer, type in “ipfs://” in its address bar and paste the hash. By clicking on the “Enter” button, the IPFS network will fetch the image.

Detailed information about using Moralis’ Rarible plugin to mint NFTs for free is available in our documentation. Moreover, the below snippet should be added to your “main.js” file:

await Moralis.Plugins.rarible.lazyMint({
  chain: 'rinkeby',
  userAddress: '0x7f64041298CC2C045FE5eb0e897ab7b5D4BdB4F3',
  tokenType: 'ERC1155',
  tokenUri: '/ipfs/QmWLsBu6nS4ovaHbGAXprD1qEssJu4r5taQfB74sCG51tp',
  supply: 100,
  royaltiesAmount: 5, // 0.05% royalty. Optional
})

You can edit the inputs for all of the above. For example, you can change from Rinkeby into the mainnet or the “TokenType” from “ERC1155” to “ERC721”. The “tokenURl” would be your metadata, and “supply” shows the number of “mints” you want to have. As stated previously, you can specify royalties for your tokens as well. In this way, after you sell your NFT, you can get a percentage of purchases made with that NFT. So feel free to change the above value into whatever you wish. Also, if you want to put your NFT for sale, you can include the following lines in the snippet:

 list: true, // only if lazy listing
  listTokenAmount: 3, // only if lazy listing
  listTokenValue: 10 ** 18, // only if lazy listing
  listAssetClass: 'ETH', // only if lazy listing || optional

Mint NFTs for Free – How to Find your NFTs on the Rinkeby Network?

Once you have uploaded the image, you will receive a 200 success message if everything goes well. The “tokenID” and “tokenAddress” would also be shown in the metadata. To check your NFT, go to the “Rinkeby.Rarible.com” website. Click on one of the tokens on the website to figure out the URL structure. The token address (or the contract address) should be followed by the token ID. Following the structure, you can build your address in the “main.js” file:

//https://rinkeby.rarible.com/token/TOKEN_ADDRESS: TOKEN_ID

Next, you should add your inputs with the above order and paste the resulting URL in the address bar. Now you should see your token just like below. Keep in mind that fetching the image from IPFS takes some time. By signing in to your account, you can control your NFT and, for example, put it up for sale.

To learn more about Moralis’ infrastructure capabilities, check out our website and the documentation. There you will find out how to integrate Moralis’ API into your dApps and build your own blockchain projects with the slightest programming skills.

Video Tutorial on How to Mint NFTs for Free Without Paying Gas Fees

As mentioned earlier, for a more detailed and in-depth explanation of the code explained herein, please see our GitHub page or make sure to watch the following YouTube video. There, Filip from Moralis goes over how to build a dApp that utilizes Moralis’ Rarible plugin:

Summary of How to Mint NFTs Without Paying for Gas Fees

The NFT market’s popularity is growing quickly, and more people get involved every day. However, minting NFTs is not free of charge when using traditional methods. To put it differently, you must spend money to sell your digital art collection. But Moralis, as a pioneer provider of the backend infrastructure for building dApps, has made it possible for free. Using Moralis’ Rarible plugin and the prefabricated code, you can mint NFTs for free and integrate this capability into your projects. The fantastic API provided by Moralis would make it possible for you to change your digital arts into digital assets. Additionally, after you learn how to mint NFTs for free, you can put them up for sale using our code snippets. Just head over to our documentation, read the instructions, and start minting NFTs for free! 

December 9, 2021
Moralis Blog
Moralis Blog
Become a Moralis Mage
Get the latest information about Moralis Web3 in your email
Search
Generic filters
Related Articles
Become a Web3 Expert
Subscribe to our newsletter and get our E-book Web3 Speed run for FREE