0

I have an upgradeable contract, but when I upgrade it, it doesn't go to the same address.

After I deploy the upgrade, the console shows TransparentUpgradeableProxy getting a new address, but that address does not have the functionality added in the upgraded contract nor the same tokens already created in the new contract. It does, however, have the functionality of the old contract.

Below are my deployment scripts:

1_deploy_upgradeable_Placeholder.js

const { deployProxy } = require('@openzeppelin/truffle-upgrades');

const Placeholder = artifacts.require('Placeholder');

module.exports = async function (deployer) {
  const instance = await deployProxy(Placeholder, { deployer });
  console.log('Deployed', instance.address);
};

and:

//2_upgrade_AlmaNFT.js

const { upgradeProxy } = require('@openzeppelin/truffle-upgrades');

const Placeholder = artifacts.require('Placeholder');
const Placeholderv2 = artifacts.require('Placeholderv2');

module.exports = async function (deployer) {
  const existing = await Placeholder.deployed();
  await upgradeProxy(existing.address, Placeholderv2, { deployer });
};

I interact with them through the truffle console, and use

const place = Placeholder.at(TransparentUpgradeableProxy address)

after which I perform functions like so:

place.function()

What am I doing wrong?

4
  • Do you get an error here? Or what is happening? Commented Oct 25, 2022 at 12:45
  • When I deploy the upgraded contract, the proxy doesn't perform the functions of the upgraded contract
    – Antheloth
    Commented Oct 26, 2022 at 22:22
  • Try interacting with the original address? A new proxy just contains new logic to use, nothing should actually be used at the address of the newly deployed functionality. Also I'm a little confused since this is all spread across multiple files and control flows, especially the const place = Placeholder.at(TransparentUpgradeableProxy address)
    – Bruce
    Commented Oct 27, 2022 at 3:32
  • I tried the original address, it still works, just without the upgrade
    – Antheloth
    Commented Oct 27, 2022 at 18:43

1 Answer 1

0

It actually works fine, I just needed to interact by writing:

const place = await Placeholderv2.at(TransparentUpgradeableProxy address)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.