Search code examples
ethereumsolidity

Solidity constructor declaration and statements between function signature and visibility modifieres


I just came across this in a Solidity contract, I don't understand it. Specifically I don't understand how there can be a function call after the constructor parameters block. If it were a modifier, it would be after "public", but it is immediately after the parameters. What does MerkleTreeWithHistory(_merkleTreeHeight) mean in this context?

  constructor(
    IVerifier _verifier,
    uint256 _denomination,
    uint32 _merkleTreeHeight,
    address _operator
  ) MerkleTreeWithHistory(_merkleTreeHeight) public {
    require(_denomination > 0, "denomination should be greater than 0");
    verifier = _verifier;
    operator = _operator;
    denomination = _denomination;
  }

Solution

  • MerkleTreeWithHistory(_merkleTreeHeight) 
    

    Calls the parent contract constructor. It is executed before entering the sub-contract constructor.