4. Write Smart Contract
Last updated
Was this helpful?
Was this helpful?
pragma solidity 0.5.6;
contract Count {
uint public count = 0; // Declare count variable as uint type and initialize its value to 0.
}pragma solidity 0.5.6;
contract Count {
uint public count = 0;
function plus() public { // 'plus'라는 이름의 public 함수를 작성합니다.
count = count + 1; // 'plus' 함수는 count 변수를 1씩 증가시킵니다.
}
function minus() public { // 'minus'라는 이름의 public 함수를 작성합니다.
count = count - 1; // 'minus' 함수는 count 변수를 1씩 감소시킵니다.
}
}function plus() public { … }pragma solidity 0.5.6;
contract Count {
uint public count = 0;
address public lastParticipant;
function plus() public { // 'plus'라는 이름의 public 함수를 작성합니다.
count = count + 1; // 'plus' 함수는 count 변수를 1씩 증가시킵니다.
}
function minus() public { // Make a public function called 'plus'
count = count - 1; // 'minus' function decreases count variable by 1.
}
}pragma solidity 0.5.6;
contract Count {
uint public count = 0;
address public lastParticipant;
function plus() public {
count = count + 1;
lastParticipant = msg.sender; // msg.sender의 값을 lastParticipant에 저장합니다.
}
function minus() public {
count = count - 1;
lastParticipant = msg.sender; // msg.sender의 값을 lastParticipant에 저장합니다.
}
}lastParticipant = msg.sender;