Timed out waiting for existing implementation

@frangio
I had the same error with deployProxy and it says

Error: Timed out waiting for implementation contract deployment to address 0x8B438C6B4cd78139A536BF8D6f5845C3ffB526A0 with transaction 0x14f9c61c01ce4dd15dfd27a46c4dc241eee7cdb18ecb47edcdbc6d7028571dfc

Run the function again to continue waiting for the transaction confirmation. If the problem persists, adjust the polling parameters with the timeout and pollingInterval options.

I checked the txHash and contract address, and it is successfully deployed, but Proxy and ProxyAdmin were not deployed yet.

First, I set the timeout & pollingInterval and tried the script again, it had the same error.
Next, I set useDeployedImplementation to true, but the new implementation contract was deployed.

How can I extend the timeout duration or rerun the script using the deployed implementation contract?

1 Like

Are you using Truffle or Hardhat. What version are you using. Please provide more detail...

You can customize the timeout passing a timeout option:

1 Like

Hi @Yuzu, can you please provide the information listed here. Thanks.

1 Like

I'm encountering the same error when deploying to local networks hosted in a Windows Docker environment, such as Ganache and Hardhat. I've already tried the following:

  1. Increased the max gas limit.
  2. Adjusted pooling parameters.
  3. Extended the timeout.

However, the deployProxy function still returns the same error. @frangio @ericglau

1 Like

@thamali002 Ganache is deprecated. If you are getting the error with Hardhat network, please provide the listed information linked from my comment above.

1 Like

Contract Code,

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract MyToken is ERC20Upgradeable, OwnableUpgradeable {
    function initialize(string memory name, string memory symbol) public initializer {
        __ERC20_init(name, symbol);
        __Ownable_init();
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }

    function burn(address from, uint256 amount) public onlyOwner {
        _burn(from, amount);
    }
}

and deployment script

require("dotenv").config();
const { ethers, upgrades } = require("hardhat");
const { getImplementationAddress } = require("@openzeppelin/upgrades-core");

async function main() {
  try {
    const provider = new ethers.JsonRpcProvider(process.env.PROVIDER_URL, {
      name: process.env.NETWORK_NAME,
      chainId: +process.env.CHAIN_ID,
      timeout: 600000,
      pollingInterval: 4000,
    });
    const owner = new ethers.Wallet(
      "PRivate key of the owner of the contract",
      provider
    );
    const Token = await ethers.getContractFactory("MyToken", owner);
    const token = await upgrades.deployProxy(
      Token,
      ["Wallet address of PK"],
      {
        initializer: "initialize",
        gasLimit: 800000000,
        kind: "uups",
        gasPrice: 800000000,
        pollingInterval: 50000,
        timeout: 600000,
        redeployImplementation: "onchange",
      }
    );
    const receipt = await token.wait();
    const implementationAddress = await getImplementationAddress(
      provider,
      token.address
    );
    console.log("Proxy TEST Token Address:", token.address);
    console.log(
      "TEST Token Implementation Contract Address:",
      implementationAddress
    );
  } catch (err) {
    console.error(err);
  }
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

For the above implementation, I'm getting @frangio error always. Hardhat deployed in docker desktop (Windows)
@ericglau

1 Like

@thamali002 Please provide all of the other information listed in Required information when requesting support for Upgrades Plugins as well, otherwise we don't have enough context to look into this.

I notice that the arguments for the initializer that you are passing in from your script ["Wallet address of PK"] do not match with the arguments of your initializer in your contract initialize(string memory name, string memory symbol). Ensure you are passing in the correct arguments.

You can also try deploying the implementation first, by using deployImplementation and waiting for that deployment to complete, then run deployProxy after.

1 Like

I just updated the Contract code and tried to deploy in both ways (deployImplementation & deployProxy)

pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract MyToken is ERC20Upgradeable, OwnableUpgradeable {
    function initialize(address adminAddress) public initializer {
        __ERC20_init('Token', 'TKN');
        __Ownable_init(adminAddress);
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }

    function burn(address from, uint256 amount) public onlyOwner {
        _burn(from, amount);
    }
}

Deployment Script

require("dotenv").config();
const { ethers, upgrades } = require("hardhat");
const { getImplementationAddress } = require("@openzeppelin/upgrades-core");

async function main() {
  try {
    const provider = new ethers.JsonRpcProvider(process.env.PROVIDER_URL, {
      name: "hardhat",
      chainId: 31337,
      timeout: 20000,
      pollingInterval: 60000,
    });
    const owner = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
    const Token = await ethers.getContractFactory("ERC20Token", owner);
    const token = await upgrades.deployProxy(Token, [], {
      initializer: "initialize",
    });
    await token.waitForDeployment();
    const implementationAddress = await getImplementationAddress(
      provider,
      token.address
    );
  } catch (err) {
    console.error(err);
  }
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Hardhat config

require("@nomicfoundation/hardhat-toolbox");
require("@openzeppelin/hardhat-upgrades");
require("dotenv").config();

module.exports = {
  solidity: {
    compilers: [
      {
        version: "0.8.20",
        settings: {
          optimizer: {
            enabled: true,
            runs: 5000,
            details: { yul: false },
          },
        },
      },
    ],
  },
  networks: {
    hardhat: {
      mining: {
        auto: false,
        interval: 5000,
      },
    }
  },

  mocha: {
    timeout: 40000,
  },
};

Run Comand

npx hardhat run ./scripts/filename.js

Plugin

@openzeppelin/upgrades-core
1.33.1

Debug Log

 @openzeppelin:upgrades:core development manifest directory: C:\Users\AVWWF2~1\AppData\Local\Temp\openzeppelin-upgrades +0ms
  @openzeppelin:upgrades:core development manifest file: C:\Users\AVWWF2~1\AppData\Local\Temp\openzeppelin-upgrades\hardhat-31337-0xc5deaf33b5a524b055fc9b6fb66e819952573c642379bae3c84d510d2be5c11e.json fallback file: .openzeppelin\unknown-31337.json +1ms
  @openzeppelin:upgrades:core development manifest directory: C:\Users\AVWWF2~1\AppData\Local\Temp\openzeppelin-upgrades +32ms
  @openzeppelin:upgrades:core development manifest file: C:\Users\AVWWF2~1\AppData\Local\Temp\openzeppelin-upgrades\hardhat-31337-0xc5deaf33b5a524b055fc9b6fb66e819952573c642379bae3c84d510d2be5c11e.json fallback file: .openzeppelin\unknown-31337.json +1ms
  @openzeppelin:upgrades:core fetching deployment of implementation 9d630fd850423f6b0a11b683f1cc92a3b5f65f31e2e55eadeb9de2ed7d643328 +3ms
  @openzeppelin:upgrades:core initiated deployment transaction hash: 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b merge: false +400ms
  @openzeppelin:upgrades:core polling timeout 60000 polling interval 5000 +4ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +0ms
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +0ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +0ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +0ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
  @openzeppelin:upgrades:core verifying deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +5s
  @openzeppelin:upgrades:core waiting for deployment tx mined 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b +1ms
Error: Timed out waiting for implementation contract deployment to address 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 with transaction 0xfaf55366a43206be9826e1f0682ab857abfc8ea55a5ea65b457f95271df7eb8b

Both are giving the above same Error.

My network is hardhat configured in a local machine Docker container When Checking the container logs we can see the implementation contract deployed already. But "Timed out waiting for implementation contract deployment to address" triggered when trying to deploy. @ericglau

I was able to run successfully proxy contract.

  1. Run Hardhat on a local machine or Docker.
  2. Write a UUPS upgradable contract using https://wizard.openzeppelin.com/.
  3. Compile the smart contract using Hardhat.
  4. Deploy the contract (the Upgradable plugin deploys the implementation contract and proxy contract together).

Sample Smart contract

// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

contract Token is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, AccessControlUpgradeable, UUPSUpgradeable {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address defaultAdmin, address minter, address upgrader)
        initializer public
    {
        __ERC20_init("Token", "TK");
        __ERC20Burnable_init();
        __AccessControl_init();
        __UUPSUpgradeable_init();

        _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin);
        _grantRole(MINTER_ROLE, minter);
        _grantRole(UPGRADER_ROLE, upgrader);
    }

    function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
        _mint(to, amount);
    }

    function _authorizeUpgrade(address newImplementation)
        internal
        onlyRole(UPGRADER_ROLE)
        override
    {}
}

Sample Deployment code

require("dotenv").config();
const { ethers, upgrades } = require("hardhat");
const { getImplementationAddress } = require("@openzeppelin/upgrades-core");

async function main() {
  try {
    const provider = new ethers.JsonRpcProvider(process.env.PROVIDER_URL, {
      name: "hardhat",
      chainId: chainId(Should be number),
    });
    const Token = await ethers.getContractFactory("Token");
    const token = await upgrades.deployProxy(
      Token,
      [address1,address2,address3],
      {
        initializer: "initialize",
        kind: "uups",
      }
    );
    await token.waitForDeployment();
    console.log("Proxy contract:", token.target);
    const implementationAddress = await getImplementationAddress(
      provider,
      token.target
    );
    console.log("Implementation contract:", implementationAddress);
  } catch (err) {
    console.error(err);
  }
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

@thamali002 Thanks for providing this information. Do you get the issue even when running with a local hardhat node (without Docker)? I wonder if it is related to your configuration.

Can you try the following to get a new Hardhat project, and see if that works? And then you can try configuring it as needed.

  1. Configure your contract on https://wizard.openzeppelin.com/
  2. On Wizard, click Download -> Development Package (Hardhat)
  3. Unzip the downloaded file.
  4. In the unzipped folder, run npm install
  5. Set the addresses for the initializer arguments in scripts/deploy.ts
  6. Run the script npx hardhat run scripts/deploy.ts

With the above configuration, I was able to successfully run. Thank you for guidance.

1 Like

3 posts were split to a new topic: Timed out waiting for implementation with custom JsonRpcProvider