# Upgradable Contracts instantiating an \`immutable\` value

**URL:** <https://forum.openzeppelin.com/t/upgradable-contracts-instantiating-an-immutable-value/28763>\
**Category:** Smart Contracts\
**Created:** [May 16, 2022, 1:09pm UTC](https://forum.openzeppelin.com/t/upgradable-contracts-instantiating-an-immutable-value/28763 "2022-05-16T13:09:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![migbash](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/migbash/32/14730_2.png) [@migbash](https://forum.openzeppelin.com/u/migbash)\
**Post date:** [May 16, 2022, 1:09pm UTC](https://forum.openzeppelin.com/t/upgradable-contracts-instantiating-an-immutable-value/28763/1 "2022-05-16T13:09:10Z")

</div>

I am trying to use an `upgradable` contract with the configuration of an `immutable` variable in the contract at constructor time, but the `upgradability` of a contract prevents it being setup in the `initializer` and needs to be set in the `constructor`...

Would using the following setup work for the initialization of the `immutable` variable in the `constructor () initialize {}` ?

Or are constructors forbidden from being used in `upgradable contracts` and the line `constructor () initialize {}` will not execute ? or is a breach of security ?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/a/a755adde79f6660bb40458172024e00c71ae378e.png)

---

<div class="post-metadata">

**Author:** ![darkWingDuckCurry](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/darkwingduckcurry/32/10606_2.png) [@darkWingDuckCurry](https://forum.openzeppelin.com/u/darkWingDuckCurry)\
**Post date:** [May 20, 2022, 9:00pm UTC](https://forum.openzeppelin.com/t/upgradable-contracts-instantiating-an-immutable-value/28763/2 "2022-05-20T21:00:32Z")

</div>

Hey migbash,  
So, according to the documentation on open zeppelin documentation, because immutable variables are stored in the bytecode, a variable instantiated as immutable would result in all proxies pointing to the same value stored in byte code, rather than the proxy pointing to the variable in in it's own storage.

So immutables look like a nono

From the docs:

## Why can’t I use `immutable` variables?

Solidity 0.6.5 [introduced the `immutable` keyword](https://github.com/ethereum/solidity/releases/tag/v0.6.5) to declare a variable that can be assigned only once during construction and can be read only after construction. It does so by calculating its value during contract creation and storing its value directly into the bytecode.

Notice that this behavior is incompatible with the way upgradeable contracts work for two reasons:

1. Upgradeable contracts have no constructors but initializers, therefore they can’t handle immutable variables.
2. Since the immutable variable value is stored in the bytecode its value would be shared among all proxies pointing to a given contract instead of each proxy’s storage.

`In some cases immutable variables are upgrade safe. The plugins cannot currently detect these cases automatically so they will point it out as an error anyway. You can manually disable the check using the option `unsafeAllow: ['state-variable-immutable']`, or in Solidity >=0.8.2 placing the comment`/// @custom:oz-upgrades-unsafe-allow state-variable-immutable` before the variable declaration.`
