-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_and_pure.sol
More file actions
28 lines (20 loc) · 959 Bytes
/
Copy pathview_and_pure.sol
File metadata and controls
28 lines (20 loc) · 959 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract fun{
uint8 public num;
function setter(uint8 _num) public { //if you are writing the state variable no keyword(view or pure) should be used.
num = _num;
}
function getter() public view returns(uint8){ //if we are reading the state variable view keyword should be used.
return num;
}
function random(uint8 abc) public pure returns(uint8){ //If we read, write the local variable without the involvment of state variable then we should use pure keyword
return abc;
}
}
/*
Note:
1.if you are writing the state variable no keyword(view or pure) should be used.
2.if we are reading the state variable view keyword should be used.
3.If we read, write the local variable without the involvment of state variable then we should use pure keyword
*/