0

The title is pretty self explanatory.

Let's say I have a contract where I defined a constant variable and this contract is using some upgradeable pattern. When I deploy a new version of the contract, theoretically I can overwrite the constant's value, since that is baked into the bytecode.

Example:

  1. First version of the contract:
contract MyUpgradeableContract {

   uint256 public constant ZERO_TO_BE_ONE = 0;

}
  1. Contract after upgrade:
contract MyUpgradeableContract {

   uint256 public constant ZERO_TO_BE_ONE = 1;

}

Is this allowed in solidity with upgradeable pattern?

1 Answer 1

1

Yes, you can override the constant, as the value doesn't occupy any storage slot, but exists in the runtime bytecode, which is deployed in the new contract.

Your Answer

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

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