Can upgradeable contracts have immutable vars?

I have an upgradeable contract (that is a factory) that has the deployable contract as an immutable var, the factory's constructor is setting the immutable var


import "./IMPL.sol";

contract Factory is OwnableUpgradeable {
  address public immutable implementation;
  constructor() {
    implementation = address(new IMPL());

  function initialize() initializer public {

IMPL is the contract the factory should deploy, and it's in another solidity file that is being imported

Please see this section of the docs about immutable variables:

Thanks for the answer! somehow that section has eluded me.

And it works great for my use case, as i want all proxies to share the same inmutable value.

1 Like