-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathICO_Test.sol
More file actions
65 lines (50 loc) ยท 1.57 KB
/
ICO_Test.sol
File metadata and controls
65 lines (50 loc) ยท 1.57 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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
contract ICO_Test is ERC1155{
struct User {
address addr;
uint[] tokensBought;
}
uint[4] tokenPrice = [
10000000000000000,
50000000000000000,
100000000000000000,
200000000000000000
];
address owner;
User[] users;
constructor() ERC1155(""){
owner = msg.sender;
}
// ํ ํฐ ๊ตฌ๋งค ํจ์
function buyToken(uint _tokenId, uint _amount) public payable {
require(tokenPrice[_tokenId] * _amount == msg.value, "check amount");
}
// ์คํ ์ ์ง๊ธํด์ผ ํ ํ ํฐ์ 1/2 ์ผ๊ด ์ง๊ธ (๊ฐ ํ ํฐ๊ฐ์ * 1/2 ๊ธฐ๋ฅ ์ถ๊ฐ ํ์)
function giveTokens() public {
require(msg.sender == owner);
uint[] memory tokenIds = new uint[] (4);
for(uint i=0;i<4;i++) {
tokenIds[i] = i+1;
}
for(uint j=0; j<users.length;j++) {
safeBatchTransferFrom(address(this), users[j].addr, tokenIds, users[j].tokensBought, "0x0");
}
}
// ํ ํฐ ํ๋งค๋ ๊ธฐ๋ก ํจ์
function getMintedAmount() public {
}
// ๊ฐ๊ฒฉ 2๋ฐฐ๋ก ์ฌ๋ฆฌ๋ ํจ์
function doublePrice() public {
require(msg.sender == owner, "only Owner");
for(uint i=0;i<tokenPrice.length;i++) {
tokenPrice[i] *= 2;
}
}
// Owner ์ธ์ถ ํจ์
function withdraw(uint _amount) public {
require(msg.sender == owner);
payable(owner).transfer(_amount);
}
}