-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vault.sol
54 lines (42 loc) · 1.51 KB
/
Vault.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IERC20 {
function transfer(address to, uint256 amount) external returns (bool);
}
contract TokenVault {
uint256 private amount_people_get;
mapping (address => bool) private whiteList;
mapping (string => bool) public ValidateCid;
string[] private myCids;
IERC20 public token;
address private owner;
constructor(address _token, uint256 count_people_get, address[] memory wallets) {
token = IERC20(_token);
owner = msg.sender;
amount_people_get = count_people_get;
for (uint256 i = 0; i < wallets.length; i++) {
whiteList[wallets[i]] = true; // make sure to set the wallets to true
}
}
modifier onlyOwner {
require(msg.sender == owner,"You are not owner this contract");
_;
}
function addWallet(address wallet) public onlyOwner {
whiteList[wallet] = true;
}
function addCid(string memory cid) public {
require(whiteList[msg.sender], "Your wallet not in white list");
require(!ValidateCid[cid], "Your Cid is exist");
bool sent = token.transfer(msg.sender, amount_people_get * 10 ** 18);
require(sent, "Filed ocean transfer");
ValidateCid[cid] = true;
myCids.push(cid);
}
function getValidCids() public view returns (string[] memory){
return myCids;
}
function getCountCids() public view returns (uint256) {
return myCids.length;
}
}