Chainlink – Resolving Deployment Issues to Polygon Mumbai While Importing ChainlinkClient.sol

browniechainlinkpolygonweb3.py

I have a contract that is deploying fine to rinkeby and kovan. I want to put it on polygon-main but thought I'd test with polygon-test (ie. mumbai) first. I'm using brownie. My deploy looks like this:

    myContract = MyContract.deploy(
      var_1,
      var_2,
      ...
      var8,
      {"from": from_account},
      publish_source=True
    )

Deploying to polygon test results in an error saying:

Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.

If I remove the import of ChainlinkClient.sol from my contract I can deploy just fine to mumbai, but I need ChainlinkClient.sol for my contract, so removing it is not really an option. So, with ChainlinkClient.sol in my contract, I then try deploying with a gas_price and gas_limit like this:

    myContract = MyContract.deploy(
      var_1,
      var_2,
      ...
      var8,
      {"from": from_account, 'gas_limit': 272692, gas_price': 9000000000},
      publish_source=True
    )

That results in this error:

ValueError: Execution reverted during call: 'out of gas'. This transaction will likely revert. If you wish to broadcast, include allow_revert:True as a transaction parameter.

So then I increase gas_limit a bit more (to 282692) and I get this error:

ValueError: Execution reverted during call: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, include allow_revert:True as a transaction parameter.

I tried using allow_revert: True, but it didn't seem to do anything… though I'm not sure I'm using it correctly. I've tried putting it in like this:

{"from": from_account,'gas_limit': 282692, 'gas_price': 9000000000, 'allow_revert': True},

This didn't change anything… I got the same error as above.

The from_account has 0.9 MATIC on polygon mumbai… and it will deploy contracts (like if I remove the import of ChainlinkClient.sol). My contract is 340 lines and deploys to kovan and rinkeby without issue. I also tried sending to polygon-main and it gave the exact same errors… however, I do not have MATIC on polygon main, so I wouldn't expect it to work there (though I would think it would show a different error if the lack of MATIC was the issue).

Any help or insight would be greatly appreciated!

Best Answer

Without the code, it's hard to tell what's going wrong. But a common issue is because of the fact that the Chainlink Client is not able to identify the LINK token contract address on the Mumbai network. If your code contains the following function in the constructor, that might be the source of error.

constructor() {
    setPublicChainlinkToken();
    //rest of the code
}

This function automatically sets the contract address of the LINK token contract for that particular network. It doesn't work properly for Mumbai Network though. So manually setting it should fix it. It can be done the following way.

constructor() {
    address mumbaiLINKContract = 0x326C977E6efc84E512bB9C30f76E30c160eD06FB;
    setChainlinkToken(mumbaiLINKContract);
    //rest of the code
}

Depending on the network you are using, you'll need to input the right contract address. The address provided in the code above is for the Mumbai testnet.

If this doesn't fix the issue, please share the rest of the code so we can take a look.

Related Topic