deployProxy regularly errors with Invalid deployment when using Infura

Hey everyone,
I often have this error while deploying an upgradeable contract via Infura:

Invalid deployment with address 0x... and 0x...

:computer: Environment

hardhat 2.0.6:
@nomiclabs/hardhat-ethers 2.0.1
@openzeppelin/contracts-upgradeable@ 3.3.0
@openzeppelin/hardhat-upgrades 1.4.3


The tx is actually sent and mined correctly but when the waitAndValidateDeployment function of the @openzeppelin/upgrades-core package checks the tx with getTransactionByHash, the provider returns null.
If I put an await sleep(5000) before that, I don’t have problems, so I guess the infura node I’m hitting doesn’t know about that tx yet.

I guess in that while loop we could retry N times even in this case, but I’m asking because I’m not sure it would be the right place to do it.

Does this happen to someone else?

:1234: Code to reproduce

    const myContract = await ethers.getContractFactory("MyContract", signer);
    const proxy = await upgrades.deployProxy(myContract, [args]);
    await proxy.deployed();

Hi @gravityblast,

Welcome to the community :wave:

I am sorry that you are having this issue.

What network are you deploying to? Have you tried using a different provider (e.g. Alchemy:

I just tried OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat using Infura to Rinkeby with no issues.

$ npx hardhat run --network rinkeby scripts/deploy.js
Compiling 1 file with 0.7.3
Compilation finished successfully
Deploying Box...
Box deployed to: 0xfD1dafA50bC4362a792531285b047C14D75c5D5b


// scripts/deploy.js
async function main() {
    const Box = await ethers.getContractFactory("Box");
    console.log("Deploying Box...");
    const box = await upgrades.deployProxy(Box, [42], { initializer: 'store' });
    console.log("Box deployed to:", box.address);
    .then(() => process.exit(0))
    .catch(error => {
1 Like

thank you @abcoathup ! It’s both with kovan and mainnet.
Yes with alchemy it seems to always work, but with infura it’s always the same so I was wondering if that change could be good to manage this problem.
If that makes sense I could open a PR.


HI @gravityblast,

After a few tries I managed to reproduce on Kovan using Infura.

I’ll check with the development team what would be the best work around.


$ rm -rf artifacts/
$ rm -rf .openzeppelin/


$ npx hardhat run --network kovan scripts/deploy.js
Compiling 1 file with 0.7.3
Compilation finished successfully
Deploying Box...
{ Error: Invalid deployment with address 0x03EB1e2956AA03a086a3511BCDaeFAcB1e438086 and txHash 0x0d18b824ea4137fce5386fb50307732987d39bdd870ecf0e836f5012be22d512
    at Object.waitAndValidateDeployment (/home/abcoathup/projects/forum/gravityblast/node_modules/@openzeppelin/upgrades-core/src/deployment.ts:66:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
   { address: '0x03EB1e2956AA03a086a3511BCDaeFAcB1e438086',
     layout: { storage: [Array], types: [Object] } } }

Hi @gravityblast.

Yes, this is very likely the reason.

I think we can safely remove the exception we raise, and continue retrying until we see something or time out.

If you would like to provide a PR, if I’m not mistaken we have to replace the following

with something like

if (tx === null) {

I should have fixed this in


great!! thank you @frangio !

1 Like

HI @frangio & @gravityblast,

It looks resolved; I haven’t been able to reproduce since upgrading to the latest version.