Polygon Mumbai Network – Resolving Infinite Transaction Pending When Interacting with Contracts

contract-deploymenterc-721hardhatpolygontokens

I am trying to implement a ERC721 NFT smart contract at polygon mumbai network.
First of all, contract code is here: https://github.com/Lorenzobattistela/melk-smart-contract

When I first deployed with hardhat, using npx hardhat run scripts/sample-script.js where the file above did this:

const Melk = await hre.ethers.getContractFactory("MelkTest")
  const melk = await Melk.deploy();
  
  await melk.deployed();
  console.log("NFT deployed to:", melk.address);

  await melk.addModule("module2");

  await melk.mintCertificate("module2","0x422F4B687050f60DfAA64BF46AabEf9dEE9605aB", "lorenzo#7506", "0x422F4B687050f60DfAA64BF46AabEf9dEE9605aB")

This worked well, I could even see the NFT at openSea and it was all working fine.

Then I tried to deploy to polygon mumbai, using a hardhat config like this:

module.exports = {
  solidity: "0.8.4",
  networks: {
    mumbai: {
      url: `https://polygon-mumbai.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY}`,
      accounts: [`${process.env.MUMBAI_PRIVATE_KEY}`]
    }
  }
};

Then I ran npx hardhat run scripts/deploy.js --network mumbai with the following being the deploy file:

deploy file

And finally I tried to interact with the contract with the following:
npx hardhat run scripts/mint.js --network mumbai

enter image description here

And that resulted in this transaction of minting:
https://mumbai.polygonscan.com/tx/0x907ef1321606313c76191d994e1ff45772c961e6d515680650c9802942be6a1c

enter image description here

And it have been pending for 20 minutes or more. WHy is this happening and how can I fix it?

Best Answer

I have recently have this issue and also stuck for a week. It seems like there are some pending transactions happening and it is stucking in the blockchain network.

To solve this, you need to follow these steps on Metamask:

  • Sending 0 matic to your own wallet from your wallet
  • Ensure to pay highest gas fee
  • Wait for sometimes (30 mins) ++
  • Depending on number of pending transactions, it can takes sometimes to finish
  • Ensure you have enough funds in wallet

If the problem still persist, you may also need to "Reset Account" in Metamask and perform above steps again.

Depending on number of many pending transactions, you will need to wait for sometimes. Please view on https://mumbai.polygonscan.com/ what transactions are happening with your wallet address.

Reference:

Related Topic