-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.sol
35 lines (28 loc) · 4.4 KB
/
functions.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
33
34
35
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract Function {
// uint256 favoriteNumber; //default visibility of the declaration in internal
//To make the visibility public:
uint public favoriteNumber;
function myFun(uint _favoriteNumber) public {
favoriteNumber = _favoriteNumber;
}
string name;
function myName(string memory _name) public {
name = _name;
}
//view keyword specifies that the function is only ment to read the values and does not modify the state
//usually view functions are denoted in blue color
function retriveFunction() public view returns (uint) {
return favoriteNumber;
}
//pure keyword disallows reading from state or storage from the entire code. It can only read values within itself. The value is not changed
function changeNumber(uint _number) public pure returns (uint) {
uint number = _number;
return number;
}
//view and pure function dont need to spend gas because they dont modify the state
//view functions does cause gas only when gas caused transaction is calling it
//input data(machine code of entire solidity code)
//0x6080604052348015600e575f80fd5b506106578061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610055575f3560e01c806307391dd61461005957806327ba83551461008957806331ec5fb1146100a7578063471f7cdf146100c357806396712958146100e1575b5f80fd5b610073600480360381019061006e9190610178565b6100fd565b60405161008091906101b2565b60405180910390f35b61009161010b565b60405161009e91906101b2565b60405180910390f35b6100c160048036038101906100bc9190610307565b610113565b005b6100cb610126565b6040516100d891906101b2565b60405180910390f35b6100fb60048036038101906100f69190610178565b61012b565b005b5f8082905080915050919050565b5f8054905090565b80600190816101229190610552565b5050565b5f5481565b805f8190555050565b5f604051905090565b5f80fd5b5f80fd5b5f819050919050565b61015781610145565b8114610161575f80fd5b50565b5f813590506101728161014e565b92915050565b5f6020828403121561018d5761018c61013d565b5b5f61019a84828501610164565b91505092915050565b6101ac81610145565b82525050565b5f6020820190506101c55f8301846101a3565b92915050565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610219826101d3565b810181811067ffffffffffffffff82111715610238576102376101e3565b5b80604052505050565b5f61024a610134565b90506102568282610210565b919050565b5f67ffffffffffffffff821115610275576102746101e3565b5b61027e826101d3565b9050602081019050919050565b828183375f83830152505050565b5f6102ab6102a68461025b565b610241565b9050828152602081018484840111156102c7576102c66101cf565b5b6102d284828561028b565b509392505050565b5f82601f8301126102ee576102ed6101cb565b5b81356102fe848260208601610299565b91505092915050565b5f6020828403121561031c5761031b61013d565b5b5f82013567ffffffffffffffff81111561033957610338610141565b5b610345848285016102da565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061039c57607f821691505b6020821081036103af576103ae610358565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026104117fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826103d6565b61041b86836103d6565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61045661045161044c84610145565b610433565b610145565b9050919050565b5f819050919050565b61046f8361043c565b61048361047b8261045d565b8484546103e2565b825550505050565b5f90565b61049761048b565b6104a2818484610466565b505050565b5b818110156104c5576104ba5f8261048f565b6001810190506104a8565b5050565b601f82111561050a576104db816103b5565b6104e4846103c7565b810160208510156104f3578190505b6105076104ff856103c7565b8301826104a7565b50505b505050565b5f82821c905092915050565b5f61052a5f198460080261050f565b1980831691505092915050565b5f610542838361051b565b9150826002028217905092915050565b61055b8261034e565b67ffffffffffffffff811115610574576105736101e3565b5b61057e8254610385565b6105898282856104c9565b5f60209050601f8311600181146105ba575f84156105a8578287015190505b6105b28582610537565b865550610619565b601f1984166105c8866103b5565b5f5b828110156105ef578489015182556001820191506020850194506020810190506105ca565b8683101561060c5784890151610608601f89168261051b565b8355505b6001600288020188555050505b50505050505056fea26469706673582212202f89f86b28747532af73099026dddb08985f17538b8ddd2ef169f036ecd5469564736f6c63430008190033
}