4. Write Smart Contract
Last updated
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 { // Make a public function called 'plus'
count = count + 1; // 'plus' function increases count variable by 1.
}
function minus() public { // Make a public function called 'plus'
count = count - 1; // 'minus' function decreases count variable by 1.
}
}function plus() public { … }pragma solidity 0.5.6;
contract Count {
uint public count = 0;
address public lastParticipant;
function plus() public { // Make a public function called 'plus'
count = count + 1; // 'plus' function increases count variable by 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; // store msg.sender to lastParticipant
}
function minus() public {
count = count - 1;
lastParticipant = msg.sender; // store msg.sender to lastParticipant
}
}lastParticipant = msg.sender;