-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrorAssesment
37 lines (35 loc) · 1.04 KB
/
ErrorAssesment
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
33
34
35
36
37
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.12 <0.9.0;
contract Error {
uint256 maxValue;
uint256 counter;
address owner;
//Constructor to initalize MAX VALUE
constructor(uint256 _maxValue){
require (0 < _maxValue, "MAX VAlUE must be greater than 0");
maxValue = _maxValue;
owner = msg.sender;
}
//function for require
function FormaxValue(uint256 _maxValue) public {
require(0 < _maxValue , "MAX VAlUE must be greater than 0");
require(msg.sender == owner, "only owner can send massage");
maxValue = _maxValue;
}
//function for assert
function incrementCounter() public{
counter += 1;
assert(counter > 0);
}
//function for revert
function forRevert(address _address) public view{
if(_address != owner){
revert("NOT owner's Address");
}
}
//function for require
function Divide(uint256 a, uint256 b) public pure returns(uint256){
require (b !=0, "divisor cannot be zero");
return a / b;
}
}