Error: Contract is not upgrade safe. Use of delegatecall is not allowed


I am trying to test deployment through a proxy.
My contract does not have any delegate calls, neither selfdestruct.
However, after


I'm getting an error that I can remove using { unsafeAllow: ['delegatecall'] }

However, something tells me there is unsafe stuff happening here.

Error: Contract `MyContract` is not upgrade safe
@openzeppelin/contracts/utils/Address.sol:185: Use of delegatecall is not allowed
      at Object.assertUpgradeSafe (node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:17:11)
      at Object.deployImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:31:3)
      at async Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:57:18)
      at async Context.<anonymous> (test/proxies/MyContract.proxy.spec.ts:33:21)

My contract is Initializable, OwnableUpgradeable, ERC20Upgradeable and uses SafeERC20 for IERC20.

Other than that, it does not use delegate call nor selfdestruct can somebody help me figure out why is my contract identified as unsafe?


I have also started experiencing this issue. Same as with @karl, there is no explicit delegate calls int the contract and it inherits from OwnableUpgradeable

1 Like

Same issue here, SafeERC20 is using address.sol which has some functions using delegatecall.

Ha, me too! You guys figure out any work around?

Hey @lou no mate; I couldn't find any workarounds.

I have raised an issue on GH about this topic. Apparently there is way to fix this. Please follow the instructions here


For anyone still encountering this issue. You need to libraries that do not rely on delegatecall, in my case it was the safeERC20. I just had to change to SafeERC20Upgradeable and IERC20Upgradeable.

Hope it helps,

Same issue here. Looks like the same OZ contracts would fail when used with Upgradeability. Is the solution to just ignore this validation when we know the delegateCall will not be triggered?