Upgrades Plugins - lost my network files

Hi!

What should we do when network file has been lost, but we still want to upgrade our contract?
Any chance we can keep using Upgrades Plugin in this situation?

Thanks!

Hi, welcome! :wave:

I am not sure, maybe you can compile contracts again and then try to use the plugin to upgrade your contracts.

Don’t think this is the case. When doing it without network file I’m getting Proxy admin is not the one registered in the network manifest error. When doing it with manually created network file that contains actual information on the last deployment I’m getting Deployment at address ... is not registered error.

Hi, have you solved your problem?

Not, yet. Trying to manually restore my network file.

guys any update on this? I also have lost my network manifest files and wondering how upgrade will work without it now. the deployment did not build the network files properly and it still shows old network files and that too not for all contracts that were deployed.

If you have the source code to your original contract you could rebuild the network file by deploy a proxy to a local network (Hardhat Network or Ganache), and then copying it over to .openzeppelin/mainnet.json changing the addresses (including the admin address) in the file to match your mainnet contracts.

Hi' @frangio sorry to bomb this post
I'm in the same situation... could you elaborate a little more your answer ?
I have deployed an upgradable contract "Contract A" some time ago
Now I'm trying to upgrade it "Contract A2", but i get this error

When you say deploy a proxy to a local network
Do you mean do like this with the previous contract on hardhat network ?:

contractA = (await upgrades.deployProxy(ContractAFactory, [
          param1,
          param2,
        ])) as ContractA;

And then copy what to the .openzeppelin/rinkeby.json ?
And after that do the actual upgrades.upgradeProxy ?
Muchas gracias!!

Hi @Anibal_Estevez, the upgrades plugin now has a forceImport function that you can use to import a previously deployed proxy, so there is no need to manually copy .openzeppelin files.

For example, you can just do the following (replace EXISTING_PROXY_ADDRESS with the address of the proxy that you previously deployed):
contractA = await upgrades.forceImport(EXISTING_PROXY_ADDRESS, ContractAFactory);

Then after that, do the actual upgrades.upgradeProxy.

1 Like

@ericglau THAT WAS AWESOME!!!
Worked like a charm

Thanks a lot!!!

2 Likes