Error: Proxy admin is not the one registered in the network manifest

:computer: Environment
Truffle v5.3.4 (core: 5.3.4)
Solidity - 0.6 (solc-js)
Node v12.18.3
Web3.js v1.3.5

:memo:Details
I am trying to do an upgradeable contract. deployment worked. First upgrade worked…then on second upgrade I get the following error:

“Error: Proxy admin is not the one registered in the network manifest”

Hi, I would like to close this topic cause it seems like this is a duplicated topic. Before posting, I think you should extensively search the internet and the forum for relevant posts. And please read this How do I ask a good question? to follow, thanks!

And there is a tutorial, I think it is helpful.

I would like to help with this but we need you to provide a lot more detail about the situation.

Are you running against Ganache or a testnet? If Ganache, is it a fork? What are the exact steps that you followed for the deployment and first upgrade, and then the second upgrade?

Thanks. It is on ropsten, contract 0x4c0D79f3fdE4455Decc9FDca56ec139BdFe42b65.

For the initial deployment I used the following deployment contract:

const { deployProxy, upgradeProxy, admin } = require('@openzeppelin/truffle-upgrades');
const Token = artifacts.require("Token");

module.exports = async function(deployer) {
  const instance = await deployProxy(Token, [], { deployer, initializer: 'init' });
  console.log('Instance', instance.address);
};

For the subsequent upgrades I created a new contract file and the following deployment code (note the “2” is just an example here, and was different for each subsequent attempt):

const { deployProxy, upgradeProxy, admin } = require('@openzeppelin/truffle-upgrades');
const Token = artifacts.require("Token_2");

module.exports = async function(deployer) {
  const instance = await upgradeProxy("0x4c0D79f3fdE4455Decc9FDca56ec139BdFe42b65", Token , { deployer });
  console.log('Instance', instance.address);
};

The first time it worked, the second time it didn’t.

Please use triple backticks to surround your code in order to get proper formatting. I’ve edited your post.

```
code here
```

Will take a look at this issue a little bit later.

1 Like

What does your network configuration look like on Truffle? (Do not share any secret information like private keys.)

This?

ropsten: {
      provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/...`),
      from: '...',
      network_id: 3,       
      gas: 7000000,      
      confirmations: 2,   
      timeoutBlocks: 200,  
      skipDryRun: true    
    },

So I tried reproducing this and was able to deploy and upgrade twice a contract on Ropsten.

I suspect that the address in your migration is wrong. I would recommend to get the address programmatically instead of hardcoding it.

One way that you can do this is by reading it from the address field of the previous version, since it will be stored in the artifact. But this may be finicky and won’t work in the future unless you commit your artifact to git.

const { deployProxy, upgradeProxy, admin } = require('@openzeppelin/truffle-upgrades');
const TokenCurrent = artifacts.require("Token");
const Token = artifacts.require("Token_2");

module.exports = async function(deployer) {
  const instance = await upgradeProxy(TokenCurrent.address, Token , { deployer });
  console.log('Instance', instance.address);
};

You can also save the address in a JSON file in one migration and read it back in the next.

When I try the way you suggest I get the error:

“Token has not been deployed to detected network” (I am using Token for the old one, and NewToken for the new one)

Also, just so I understand…is the existing address supposed to be the address for the “TransparentUpgradeableProxy”. Should this be changing?

–update. ok, so I realized that you are getting the address directly from TokenCurrent. I was trying:

const existing = await Token.deployed();

Yes although that should also work.

Yes, this is the address of the proxy, and it should not change once it’s been deployed.

If you run deployProxy in a migration (passing in the deployer argument), the plugin will store the proxy address in the artifact as a deployment of the contract. So this is why Token.address or Token.deployed() should be working.

Hello

I deleted the JSON file under the .openzeppelin file by mistake, which caused below error when I upgraded
Error: Proxy admin is not the one registered in the network manifest

What should I do? Please help me @redbeard

Can I restore it @frangio

I have fix this error.I restore the json through mock all versions upgrade process in local ganache,and get the each upgrade records,and then replace local chain net to public net contract address and txhash.Finally,it works!