본문 바로가기

solidity

Struicture of a Contract

Struicture of a Contract

Contract can inherit from other contracts.


State Variables

Permanently stored in contract storage.


contract SimpleStorage {

uint storedData;

}


Functions


contract SimpleAuction{

function bid() public payable{

}

}


Function Modifiers


contract Purchase {

modifier onlySeller(){

}


function abort() public onlySeller {

}

}


Events


contract SimpleAuction {

event HigestBidIncreased(); //선언만 하고 구현은 다른 곳에서


function bid() public payable {

emit HigestBidIncreased();

}

}


Struct Types


contract Ballot {

struct Voter {

uint weight;

bool voted;

address delegate;

uint vote;

}

}


Enum Types


contract Purchase {

enum State { Created, Locked, Inactive } //Created는 어떤 상태를 나타내지 값을 갖는 변수가 아니다.

}

'solidity' 카테고리의 다른 글

Units and Globally Available Variables  (0) 2018.02.28
Types  (0) 2018.02.26
layout of a solidity source file  (0) 2018.02.26
modifier and payable  (0) 2018.02.23
Solidity by Example Auction  (1) 2018.02.22