November 2018
Intermediate to advanced
528 pages
13h 21m
English
As with object-oriented programming (OOP), you can define a constructor for your contract. It's a special function using the same name as the contract it belongs to. Unlike in OOP, a contract's constructor is invoked once and only once during the first deployment to the blockchain, and usually defines the initial contract behavior.
In the MyAuction contract, our constructor is extremely simple:
function MyAuction (uint _biddingTime, address _owner,string _brand,string _Rnumber) public { auction_owner = _owner; auction_start = now; auction_end = auction_start + _biddingTime* 1 hours; STATE = auction_state.STARTED; Mycar.Brand = _brand; Mycar.Rnumber = _Rnumber;}
This constructor, upon creation, sets the relevant states by defining ...
Read now
Unlock full access