Gasless NFT Minting Using USDC: Powered by Gelato Relay
Gelato Team
•
Jun 20, 2023

Non-Fungible Tokens (NFTs) have reshaped how we perceive and trade digital assets. But one barrier still hinders mainstream adoption — the need for a native gas token to transact on the network.
By combining Gelato Relay with USDC, this barrier can be removed. In this guide, we’ll show you how to integrate gasless minting into your next NFT project.
How it works
The user signs an off-chain permit signature that allows the NFT contract to spend a specified amount of USDC.
The arguments and signature are submitted to Gelato using the Relay SDK, and executed on-chain by a relayer.
The mint function uses the signature to permit itself to spend USDC: one USDC is used to pay for the NFT, and some covers the relay fee. The permitted amount includes overhead for gas price fluctuations — the full amount is rarely spent.
Requirements
Permit spending of USDC using an off-chain signature
Compensate the relayer by paying a fee
By leveraging USDC permit signatures and Gelato Relay, we can enable a truly gasless experience. Since relayers put transactions on-chain, they incur a gas cost that must be compensated — either by sponsoring via 1Balance or by paying synchronously within the transaction. The latter lets us use USDC to cover both the NFT and the relay fee in the same transaction.
Prerequisites
Install Node.js, NPM, and Git
Set up a Web3 wallet such as MetaMask
Configure an RPC provider
Your Dev Environment
Find the full source code and deployment instructions on GitHub.
Code Explanation
The NFT contract is a typical ERC721. The deployer specifies the payment token (USDC) and price. Users call the mint
function, which transfers payment tokens and mints the NFT. The supply is incremented to set token IDs.
Traditional NFT Contract
Gasless NFT Contract
To support gasless minting, we modify mint
to accept permit arguments. It uses onlyGelatoRelay
from GelatoRelayContext
to ensure only relayers can call it. This prevents malicious use and gives access to fee data and utilities.
Note: ERC-2771 is usually recommended, but here authentication is handled by USDC’s ERC-2612 permit implementation.
Frontend Implementation
The frontend estimates the relay fee and signs a permit to allow the NFT contract to spend USDC (price + fee). It then builds the request and submits it with callWithSyncFee
via the Relay SDK.
Note: For clarity, certain checks are omitted. See the full repo here.
Conclusion
Gasless NFT minting enhances UX and paves the way for mainstream adoption. By leveraging USDC permit signatures and Gelato Relay, users can mint NFTs without needing native gas tokens — secure, seamless, and trust minimized.
About Gelato Relay
Gelato abstracts away blockchain complexities, providing secure gasless transactions and a smooth onboarding experience.
Explore Relay alongside other Gelato services like Web3 Functions, Automate, and the Account Abstraction SDK.
Join our developer community on Discord!