When is a contract constructor called?

Viewed 1122

From this solidity doc I know that the constructor is called once when the contract is created. But are there other instances that the constructor is called?

I am looking for all possible cases that the constructor of a contract will be called to better understand the use of a constructor in smart contracts and the consequences of not having a constructor.

1 Answers

No. As it say in the docs, constructor is called only once.

When a contract is created, its constructor (a function declared with the constructor keyword) is executed once.

It would a huge security breach, if it could be called more than once, since constructor usually sets up contract ownership and other important variables.

Parity hack happened exactly because it was possible to call the "contructor" muliple times using delegatecall.

Related