Issue with upgradeToAndCall for 1967 Proxy Address and UUPS Implementation: Revert Error on Upgrade Attempt"

I am facing an issue when trying to upgrade my proxy contract (ERC1967) to a new UUPS implementation using the upgradeToAndCall function. I have successfully deployed a new implementation contract, and I’m using an admin account that is correctly set up.

When I call the upgradeToAndCall function to upgrade the proxy to the new implementation, the transaction reverts with the following error:
execution reverted: ProviderError: execution reverted

This is the error message I’m receiving:
UNPREDICTABLE_GAS_LIMIT (reason="execution reverted", method="estimateGas", transaction={"from":"0xEEaa75E151A720246643e466FB406F8C885e7b77","to":"0x12E3F1E155BDB237DCB6e0f7AF341ddC925cd102", ...})

The proxy address is ERC1967, and the new implementation follows the UUPS upgrade pattern. The admin account is correct, and I’ve checked the contract logic and admin permissions thoroughly, but I can’t seem to resolve the issue.

Could you please help me understand why the transaction might be reverting or how I can better troubleshoot the gas estimation issue?

Environment:

  • Solidity: ^0.8.20
  • OpenZeppelin Contracts: latest version
  • Proxy Type: ERC1967
  • Implementation Type: UUPS
  • Network: Mainnet
  • Using Hardhat for development and deployment

Does it work if you try to upgrade it on a local development network (or a network fork)?

For your error, see if there is a reason included somewhere in the error message, as described in https://github.com/NomicFoundation/hardhat/issues/2248#issuecomment-1291783312. Or try manually specifying a gas limit for the transaction.