deployProxy to Hardhat node

:computer: Environment:
@openzeppelin/hardhat-upgrades”: “^1.4.3”
“hardhat”: “^2.0.7”

Hey everyone. I’m trying to deploy my upgradeable contract using Hardhat/Ethers and OpenZepplin Upgrades.
I’m able to deploy just fine using the “deploy.js” script (rinkeby), however things fall apart when trying to deploy to the local “hardhat node”.

:1234: Code to reproduce

        const web3provider = new Web3HttpProvider('http://localhost:8545')
        const deploymentProvider = new ethers.providers.Web3Provider(web3provider)

        let contractFactory = new ethers.ContractFactory(Artifact.abi, Artifact.bytecode, deploymentProvider.getSigner())
        // NOTE: await contractFactory.deploy() works here
        contractInstance = await upgrades.deployProxy(contractFactory, [
            process.env.TEST_FORWARDER_ADDR
        ])
        await contractInstance.deployed()

ERROR:

Error: Invalid deployment with address 0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1 and txHash 
0x9ec13a37944a361c9e66a12f0aad413ec63c3e026607a6665bb3c94cf5ac6b43
      at Object.waitAndValidateDeployment (node_modules/@openzeppelin/upgrades-core/src/deployment.ts:66:15)
      at processTicksAndRejections (node:internal/process/task_queues:93:5)
      at fetchOrDeployGeneric (node_modules/@openzeppelin/upgrades-core/src/impl-store.ts:42:5)
      at Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:45:18)
      at Context.<anonymous> (test/gsn.test.js:23:28)

In my local hardhat node terminal, I do see a message saying the initial contract deployed:

  Contract deployment: MyContract
  Contract address:    0xc5a5c42992decbae36851359345fe25997f5c42d
  Transaction:         0x9be5b489e070069692e51feff5e0d598b8e6ea07e08d997c8771f7cef58866d1
  From:                0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
  Value:               0 ETH
  Gas used:            310617 of 310617
  Block #32:           0x77e5c9dc0046f6c1019877af68490a3d5edada6569d9f9bc9304138709ea9771

But there isn’t an associated ProxyContract being deployed

1 Like

SOLUTION:

// using this function to initialize the factory works!
const contractFactory = await ethers.getContractFactory("MyContract")
2 Likes

Hi @mreedr,

Welcome to the community :wave:

If you haven’t already, I suggest looking at: OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat