Failed to deploy contract on Polygon, with no error message

I made repeated attempts to deploy a fairly basic ERC-721 contract to Polygon via Infura (using HardHat). It apparently accepted the transaction, but on waiting for receipt it just kept polling. Nothing ever showed on Polygonscan. Network setup in HardHat was:

    polygon: {
      url: "https://polygon-mainnet.infura.io/v3/" + INFURA_KEY,
      accounts: [PRIVATE_KEY],
    }

(with both INFURA_KEY and PRIVATE_KEY confirmed to be correct). I tried the default gas price, and several higher values (+10, 25, 50%, and also fixed 75 gwei when base price was around 30 gwei).

The following worked, with no changes to the deployment code or env vars:

    polygon: {
      url: "https://polygon-rpc.com/",
      accounts: [PRIVATE_KEY],
    },

If you can check in your logging system from yesterday evening in ET, here are a few of the transaction hashes for the failed cases:

  • 0x4fca0b020d64712c5db1c4a0e662fbc15e1b421c314dcfcaed722cbfeb5ace17
  • 0x90d70992b84ce2bfb76e178c0ddba31cf15e1bb40d044156d5b9ca43f91cbf09
  • 0x8785f5d016d1ed29a3e1a449ad8c25962e0952d52261cb590bb47bc720a7be45

Thanks

The key part of the deployment code, using ethers.js, was:

  const [deployer] = await ethers.getSigners();
  const HK = await ethers.getContractFactory("HamsterKingdom");

  const feeData = await deployer.provider.getFeeData();
  // const gasPrice = Math.floor(Number(feeData.gasPrice) * 1.25);
  const gasPrice = ethers.utils.parseUnits("75", "gwei");
  console.log("Current gas price [gwei]:", ethers.utils.formatUnits(feeData.gasPrice, "gwei"));
  console.log("Using gas price [gwei]:", ethers.utils.formatUnits(gasPrice, "gwei"));
  
  console.log(`deploying contract at ${new Date()}...`);
  const contract = await HK.deploy(HK_BASE_URI, { gasPrice: gasPrice });
  console.log("Contract address:", contract.address);
  console.log("deploy tx:", contract.deployTransaction);

  console.log(`waiting on deploy tx...`);
  const receipt = await contract.deployTransaction.wait();
  console.log(`receipt at ${new Date()}:`, receipt);

The call to deploy returned OK, but the call to contract.deployTransaction.wait() blocked forever.

With debugging code added:

  deployer.provider.on("debug", function (e) {
    delete e.provider;
    console.log("debug event:", e);
  });

I could see that the deploy call’s polling for the deployed transaction found it after a few seconds, but then the wait's polling for the receipt never found one.

Bueller? … Bueller? …

Hey,

It might be caused by this change required by Polygon perhaps the 75 one is being blocked by the underpriced ones. Can you let me know what is the from address you’re using to deploy ?

Thanks !