POLYGON main net fails deploy, mumbai fine, other chains fine, but why?

For some reason, deployment of our OZ starter will not work on Polygon mainnet.

But passes on ETH/AVAX/BSC/FANTOM.

It also works on MUMBAI, quickly too.

Source code: defido/XDOZstarter

NPM INSTALL, then fill in your env file, then npx hardhat xdeploy

Any ideas on what might not be working?

My experience is on the Polygon mainnet, one has to manually set the gas prices. Metamask and Remix set them at extremely low values and contracts can never be picked by miners.

Thanks, but the deployment is done using HardHat, testing many, many RPC's and deployable on Mumbai without many issues, and on at least 4 other EVM based chains, such as Avalanche, Fantom, ETH mainnet etc.

It is only polygon mainnet where it fails.

AFAIK, only Polygon mainnet has that requirement. That might be the cause.

Yeah, we set these manually, can set up to 15 million. Don't believe that is it.

Polygon has been acting really weird for the past few months. You could try changing the RPC Url if it fixes it or just increase the gas limit.

Check gas price, not the limit

So I tried a deploy using salt and bytecode on polygonscan, using metamask, and paid to speed it up. It seems that the RPC nodes are SLOW. This chain is just unreliable. ETH/EVM original might be expensive but at least It's reliable. I got the message "This has been picked up by secondary nodes". When I deploy using polygonscan

The reason the deployer is failing is because it's taking forever to be included into the block and so the terminal doesn't register it.

We will recommend manually deploying on polygon scan for this.

Mumbai is great. Main net is not. The test I did over 1 hour ago is STILL pending.

If you are still using the old matic vigil rpc it was not working last time I checked. Maybe switch the provider to polygon-rpc.com

Also, since EIP 1559 you have to provide the maxGasFees and maxPriorityFees.
Otherwise your transaction will be pending for a long time and display the from address as being address 0

We try the polygon-rpc.com mostly, but also alchemy, Moralis and other reliable RPC's.

Even manual deploys are slow, 50 minutes.

We believe this is just how the Polygon network. No other chain has this issue.

I can try EIP 1559 but don't believe that is it.

You could also try to create a simple task to deploy without using a load of packages.

1 Like

I'm going to look into EIP-1559 today with hardhat and see how to get that working.

defido/XDOZstarter The code base is open source. You can actually see how deployment works.

EIP-1559 is set automatically in ethers

I saw it but this is not how I use it. I use hardhat ethers to deploy and upgrade within a task.

2 Likes

EIP-1559 was it, the maxPriority is the issue, we aren't setting a value high enough, I have tried doubling the max that MetaMask recommends and the deployments go from 50 minutes to under 2 minutes.

Apparently it was all about money in the end. "Cheap and fast" is not Polygon, "Pay us and you'll get fast" is.

Thanks!

{"method":"eth_getTransactionReceipt","params":["0xf1cf78fd730683b0935235dac1b97b67ab833b6754db2cd88c81568d6ec8efcb"],"id":411,"jsonrpc":"2.0"}

{"jsonrpc": "2.0", "id": 411, "result": null}

The EIP change worked briefly but getTransactionReciept returns null.

We are running into the same issue. Remix ended up working but it would be great if the hardhat script that works on mumbai would work on polygon mainnet.

1 Like

I'm just a regular developer that try to get things working and share my experience but I have no affiliation with Hardhat or Polygon.

The best way to work these issues is to use ethers.js plain and simple. All these tools are nice but often lead into vulnerabilities or late update that break things until they are updated.

Hard to tell I am unable to find this transaction hash on Tenderly.
Tenderly is a tool I use to debug transaction. It will show you every step your transaction went trough providing that the contract has been verified.

Yeah they actually don't go through.

It hits the RPC, being alchmemy for testing, and the getTransactionReciept is null.

The interesting and frustrating part is, sometimes it works, sometimes it doesn't.

Mainnet is so random!

I can do this via the deployer using metamask, without fault. And Mumbai, which seems to be more stable or upto date, works fine.

It's only the deployment to Mainnet with the deployment script that seems to make Polygon randomly pass then fail, then pass. But it's about 99% fail and 1% random pass.