0

How can I tell which function is the constructor function?

In the OpenZeppelin implementation of the MultisigWallet, OpenZeppelin claims this is the constructor function:

/**
   * Constructor, sets the owners addresses, number of approvals 
     required, and daily spending limit
   * @param _owners A list of owners.
   * @param _required The amount required for a transaction to be 
     approved.
   */

function MultisigWallet(address[] _owners, uint256 _required, uint256 _daylimit)
    Shareable(_owners, _required)
    DayLimit(_daylimit) { }

My problem is that I cannot tell the difference between this function and any other function.

How do I identify constructor functions?

2

In older contracts, constructors will be a function with the same name as the contract they're in. In newer contracts, the constructor will be labeled as constructor in place of function ContractName.

  • Is there any reason this constructor function does not have a {} after the parameters? – Julian Martinez Nov 29 '18 at 15:36
  • The lines following the parameters, Shareable(_owners, _required) and DayLimit(_daylimit), are the super constructors. Those are calling the constructors of parents when you call the MultisigWallet constructor. The brackets after the DayLimit(_daylimit) are the ones where you would put code to execute in the constructor. – flygoing Nov 29 '18 at 15:38

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.