How to deploy NFT smart contract on Polygon testnet for free

Looking for a cost-free way to test my NFT smart contract

I’ve been working on an NFT project and found a tutorial that shows how to set up smart contracts. The problem is that the example uses Ethereum mainnet and testnets that still cost money for gas fees.

Here’s my current Hardhat configuration:

require('dotenv').config();
require("@nomiclabs/hardhat-ethers");

const { API_KEY, WALLET_PRIVATE_KEY } = process.env;

module.exports = {
   solidity: "0.8.4",
   defaultNetwork: "goerli",
   networks: {
    hardhat: {},
    goerli: {
      url: `https://eth-goerli.g.alchemy.com/v2/${API_KEY}`,
      accounts: [`0x${WALLET_PRIVATE_KEY}`]
    },
    mainnet: {
      chainId: 1,
      url: `https://eth-mainnet.g.alchemy.com/v2/${API_KEY}`,
      accounts: [`0x${WALLET_PRIVATE_KEY}`]
    },
  },
}

I want to test my NFT contract without spending real money on gas fees. Can someone help me modify this config to use Polygon’s Mumbai testnet instead? I heard it’s completely free and works well for testing NFT contracts. What network settings do I need to change?

Mumbai testnet has been perfect for NFT testing

Switched to Mumbai 6 months ago after Goerli fees got annoying. Add Mumbai to your networks object - use https://polygon-mumbai.g.alchemy.com/v2/${API_KEY} for RPC and chainId 80001. Leave gas settings default since Mumbai handles it automatically.

Caught me off guard at first - you need MATIC tokens from Mumbai faucet, not ETH. Polygon faucet works great and gives enough test tokens for hundreds of deployments. I’ve deployed 50+ test contracts there, zero issues.

Transaction confirmations are way faster than Ethereum testnets - usually under 10 seconds. Makes iterating on contracts much smoother during development.

hey ava61! totally get why you’d want to switch to mumbai - those ethereum gas fees are brutal even on testnets :sweat_smile:

i’m curious about your setup though - same contract code or need adjustments for polygon? i’ve deployed a few nft projects on mumbai and it’s been smooth, but sometimes functions behave differently.

for hardhat config, add mumbai to your networks section. rpc url: https://polygon-mumbai.g.alchemy.com/v2/${API_KEY} (if you’re using alchemy) and chainId is 80001. update your defaultNetwork to “mumbai” instead of “goerli”.

got test MATIC tokens yet? you’ll need those for deployment. polygon faucet works well but sometimes takes a bit to process.

what kind of nft contract? erc721 or erc1155? asking because i’ve noticed some quirks with metadata handling on polygon vs ethereum that might matter for your use case.

mumbai testnet is def the way to go! just switched from goerli last month and saved tons on gas. you’l need to add mumbai network config with chainId 80001 and grab some test matic from the polygon faucent. works perfectly for nft testing.