-
Notifications
You must be signed in to change notification settings - Fork 0
/
Token Vault Contract
120 lines (77 loc) · 1.81 KB
/
Token Vault Contract
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//Token Vault Contract
//Address
//Lock and Unlock Functions
function lockTokens(
address _tokenAddress,
uint256 _amount,
uint256 _unlockTime,
address payable _withdrawer
)
public returns (uint256 _id)
/Parameter
Description
_tokenAddress
Address of the token locked.
_amount
Number of tokens locked.
_unlockTime
Timestamp number marking when tokens get unlocked.
_withdrawer
Address where tokens can be withdrawn after unlocking./
//Function for locking tokens in the vault.
function withdrawTokens(
address _tokenAddress,
uint256 _index,
uint256 _id,
uint256 _amount
)
external
/Parameter
Description
_tokenAddress
Address of the token to withdraw.
_index
Index number of the list with Ids.
_id
Id number of the locked item.
_amount
Number of tokens to withdraw./
//Function for withdrawing tokens from the vault.
//Read-Only Functions
function getItemAtUserIndex(
uint256 _index,
address _tokenAddress,
address _user
)
external view returns (uint256, uint256, address, uint256)
/Name
Description
_index
Index number of the list with Item ids.
_tokenAddress
Address of the token corresponding to this Item.
_user
User address./
//Function to retrieve data from the Item under user index number.
function getUserLockedItemAtIndex(
address _user,
uint256 _index
)
external view returns (address)
/Name
Description
_user
User address.
_index
Index number.
Function to retrieve token address at desired index for the specified user./
function getLockedItemAtId(uint256 _id)
external
view
returns (uint256, uint256, address, uint256)
/Name
Description
_id
Id number./
//Function to retrieve all the data from Item struct under given Id.