-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalpha.sol
32 lines (26 loc) · 846 Bytes
/
alpha.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract SimpleCheck {
uint private value;
// This function demonstrates `require`
function setValue(uint _value) public {
require(_value > 0, "Value must be greater than 0");
value = _value;
}
// This function demonstrates `revert`
function divideValue(uint divisor) public view returns (uint) {
if (divisor == 0) {
revert("Divisor cannot be zero");
}
return value / divisor;
}
// This function demonstrates `assert`
function doubleValue() public {
uint previousValue = value;
value *= 2;
assert(value == previousValue * 2); // Assert that the new value is double the previous value
}
function getValue() public view returns(uint){
return value;
}
}