Invalid deployment when forking network on Hardhat

:computer: Environment
hardhat: 2.0.3
@openzeppelin/upgrades-core: 1.3.1
@openzeppelin/hardhat-upgrades: 1.3.0

I am using OpenZeppelin Upgrades with Hardhat Forking Network, but when I try to Test/Deploy I keep getting this error.

Error: Invalid deployment with address 0xe7f1725E7734CE288F...... and txHash 0x4ebb5224a87d6875669d1bb6126d..................

Sometimes, one of the contracts gets deployed successfully, and then it stuck in one of the other ones.

I traced the @openzeppelin\upgrades-core and the problem stands here:

Since is a forked network, chainId = 1 and it markes the env as production. Is there any way to ignore this issue?


Hi @drbullock,

I am sorry that you had this issue. I was able to reproduce and have created an issue:

1 Like

This is happening because the Upgrades plugin stores the network state according to the chain id, but since you’re working with a fork the state doesn’t really reflect the network’s, and subsequent runs realize this and fail.

One workaround could be to customize the chain id. This is possible on Ganache but doesn’t seem possible in Hardhat Network. I’ve opened an issue:

We will see what we can do to fix this out of the box in the Upgrades plugin.


In this case, I will try to make the tests with ganache. Thank you!

1 Like