0

I'm reading through some smart contracts and I noticed functions being called in the head of the constructor function, like MarginAdmin() in the following example.

constructor(address vault, address proxy)
    public
    MarginAdmin()
{
    state = MarginState.State({
        VAULT: vault,
        PROXY: proxy
    });
}

In this case, MarginAdmin is another solidity contract that is being imported into this file. What does this mean when a function gets called like this in the head of constructor function?

1

I assume the contract in question inherits from MarginAdmin (e.g. contract Foo is MarginAdmin).

MarginAdmin() is how the constructor for MarginAdmin (the "base class") is invoked.

See https://solidity.readthedocs.io/en/v0.4.24/contracts.html#inheritance for more details about contract inheritance.

  • That's correct. The only thing which bothers me in this case is why to call constructor without parameters ? It would be called anyway...Isn't it ?I think you can skip it and don't call MarginAdmin() at all. – Rob Magier Jul 12 '18 at 20:00
  • Yes, I believe there's no need to explicitly invoke a parameterless constructor in the base class. – smarx Jul 12 '18 at 20:05
  • That seems like an unrelated question. Please create a new question to ask it. – smarx Jul 12 '18 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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