Initializable.sol isInitialised modifier

I think i know the answer already but i was just wondering what the reason is as to why you cannot check if a contract has been initialised (via a modifier or a getter)?

Use case: you may not want a function/functions to be run unless the contract has been initialised (Not using a constructor as contract is upgradable)

my guess is this is implementation specific functionality so it has no place in Initializable.sol is that correct? or is it possibly something thats been overlooked and does have a place in Initializable.sol?

1 Like

Hi @Rick_Sanchez,

Initialization is the equivalent of a constructor. Why would you want to call any function when the state variables haven’t been initialized?

There was a discussion on this in https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1541

1 Like

Sorry maybe my question wasn't clear.

Why would you want to call any function when the state variables haven’t been initialized?

This was the point i was trying to make, there is no guarantee the deployer will call the initialisation function on deployment and i wouldn't want anyone calling the other contract functions unless the initialiser function as been called (which is why access to the initialised var in initialzable.sol may be needed ).

Thanks for the link, they are talking exactly about my question. ill hop over to that discussion instead of carrying on the same discussion here.

as always thanks for your time, appreciate it.

1 Like