I am trying to understand the order of invocation of base class constructors in the presence of multiple inheritance. As far as I can tell, the order appears under-specified in the Solidity documentation below:

http://solidity.readthedocs.io/en/develop/contracts.html#arguments-for-base-constructors http://solidity.readthedocs.io/en/develop/contracts.html#multiple-inheritance-and-linearization

I have also gone through related questions in Stackexchange, but they do not address the issue with chaining multiple base constructors.

My understanding from Remix is that order of invocation of base constructors depends on the order of inheritance of the derived contract, and does not depend on the order in the constructor. For example, in both the cases below, the constructor for B is invoked before C.

contract B {
    function B() public {emit PrintB();}
    event PrintB();

contract C {
    function C() public {emit PrintC();}
    event PrintC();

contract D is B, C {
    function D() C() B() {}

contract E is B, C {
    function E() B() C() {}

Can someone confirm if my understanding is correct?

If indeed my understanding is correct, is it documented in the Solidity specification, or is it just a feature of the current implementation and may change in the future.

Thanks for your help!

  • The issue is different from the one pointed out. As far as understand, the C3 linearization of the inherited contracts is used to determine the method resolution order (which version of a method Foo in the contract hierarchy should a call Foo(..) be dispatched to). The question in ethereum.stackexchange.com/questions/21060/… is a clarification about the linearization. However, C3 linearization does not talk about the order of constructor calls when several constructors are chain in the derived contract, which was my question. Commented Apr 3, 2018 at 18:09

1 Answer 1


Yes, your understanding is correct. As pointed out in the docs you linked to, Solidity follows C3 Linearization in which the order of execution is determined by the order of the declaration at the contract level and has nothing to do with the order in which you call/pass arguments up from the constructor signature.

Solidity follows the path of Python and uses “C3 Linearization” to force a specific order in the DAG of base classes. This results in the desirable property of monotonicity but disallows some inheritance graphs. Especially, the order in which the base classes are given in the is directive is important.

  • thanks for your input. I am still not sure that C3 linearization implies your comment the order of execution is determined by the order of the declaration at the contract level. The linearization clearly determines the method resolution order (and hence the order of base classes in contract inheritance is important), but I am not sure if it also determines how a chain of base constructors is ordered. I will wait to see if I can receive some more clarification. Commented Apr 3, 2018 at 18:57

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