forked from murughan1985/solidity-language-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValueTypes.sol
More file actions
71 lines (57 loc) · 1.29 KB
/
ValueTypes.sol
File metadata and controls
71 lines (57 loc) · 1.29 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pragma solidity >=0.4.25 <0.6.0;
contract ValueTypes
{
//Boolean
bool isTrue = false;
function getBooleanVariable() public view returns (bool)
{
return isTrue;
}
//Signed Integers
int item4 = -1;
int item5 = -6535;
function getInt() public view returns (int)
{
return item5;
}
//Unsigned Integers
uint item = 5;
uint8 item2 = 255;
uint16 item3 = 65535;
function getUInt() public returns (uint, uint8, uint16)
{
item = 20;
return (item, item2, item3);
}
//Address
address owner;
address payable owner2;
function getAddress() public returns (address)
{
owner = msg.sender; //Assign user address to owner variable
return owner;
}
function transferEther() public
{
if (owner2.balance < 30 && owner.balance >= 30)
{
owner2.transfer(30);
}
}
//Bytes
function getBytes() public pure returns (bytes1, uint)
{
bytes1 byteVar = 0x65;
uint itemInt;
assembly {
itemInt := byte(0, byteVar)
}
return (byteVar, itemInt);
}
//Enums
enum gender {male, female, others}
function getEnums() public pure returns(gender)
{
return gender.female;
}
}