-
Notifications
You must be signed in to change notification settings - Fork 7
/
ValueTypes.vy
59 lines (41 loc) · 1.03 KB
/
ValueTypes.vy
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
# @version 0.3.9
# 布尔值
is_bool: public(bool)
# 数值
int256_number: public(int256)
uint256_number: public(uint256)
decimal_number: public(decimal)
# 地址
owner: public(address)
# 字节
bytes32_hash: public(bytes32)
bytes_hash: public(Bytes[66])
# 字符串
string_name: public(String[5])
@payable
@external
def __init__():
self.is_bool = True
self.int256_number = -1
self.uint256_number = 1
self.decimal_number = 1.1
self.owner = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
self.bytes32_hash = 0x4f8b61438cf1d5e6f4f684d62bf496fc8975999b940392b49a2b70e209a69c12
self.bytes_hash = b"0x4f8b61438cf1d5e6f4f684d62bf496fc8975999b940392b49a2b70e209a69c12"
self.string_name = "Vyper"
@view
@external
def bool_operations() -> (bool, bool, bool):
x: uint256 = 100
y: uint256 = 200
return x < y, x > y, x == y
@view
@external
def number_operations() -> (int256, uint256, decimal):
x: int256 = -100
y: int256 = 200
x1: uint256 = 100
y1: uint256 = 200
x2: decimal = 100.0
y2: decimal = 200.0
return x - y, x1 + y1, x2 * y2