KLAYswap
Search…
Set EcoPot

1. Contract Deploy

Deploy Guide
EcoPot Operator Smart Contract Code
  • The token and project name for EcoPot are set at the time of creation and cannot be modified.
  • Please check whether the contract is deployed in the public environment
  • Please pay attention to the security of the Owner account.
  • Please refer to Klaytn's Smart contract deployment here.
1
pragma solidity 0.5.6;
2
3
interface IKIP7 {
4
function balanceOf(address account) external view returns (uint256);
5
function transfer(address recipient, uint256 amount) external returns (bool);
6
function approve(address spender, uint256 amount) external returns (bool);
7
function decimals() external view returns (uint8);
8
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
9
}
10
11
interface EcoPotLike {
12
function totalAmount() external view returns (uint);
13
function amountPerBlock() external view returns (uint);
14
function distributableBlock() external view returns (uint);
15
function estimateEndBlock() external view returns (uint);
16
function operator() external view returns (address);
17
function getDistributedCurrent() external view returns (uint);
18
function isInitialized() external view returns (bool);
19
function isAvailable() external view returns (bool);
20
21
function initialize(uint, uint, uint) external payable;
22
function depositKlay() external payable;
23
function depositToken(uint) external;
24
function refixAmountPerBlock(uint) external;
25
}
26
27
interface EcoPotVotingLike {
28
function ecoPotExist(address) external view returns (bool);
29
}
30
31
contract EcoPotOperator {
32
address constant public ecoPotVoting = 0x2ce59e21364DcA92c90970AD15442146D638997f;
33
address constant public ksp = 0xC6a2Ad8cC6e4A7E08FC37cC5954be07d499E7654;
34
35
address public owner;
36
address public nextOwner;
37
38
address public ecoPot;
39
address public token;
40
string public name;
41
42
constructor(address _token, string memory _name) public {
43
owner = msg.sender;
44
45
token = _token;
46
if(token != address(0)) require(IKIP7(token).decimals() != 0);
47
name = _name;
48
}
49
50
function version() external pure returns (string memory) {
51
return "EcoPotOperator20220221A";
52
}
53
54
// valid fallback
55
function () payable external { }
56
57
// ======================= owner method ===========================
58
59
modifier onlyOwner {
60
require(msg.sender == owner);
61
_;
62
}
63
64
function changeNextOwner(address _nextOwner) public onlyOwner {
65
nextOwner = _nextOwner;
66
}
67
68
function changeOwner() public {
69
require(msg.sender == nextOwner);
70
71
owner = nextOwner;
72
nextOwner = address(0);
73
}
74
75
//withdraw tokens remaining in the operator contract
76
function withdraw(address tokenAddr) public onlyOwner {
77
uint balance = 0;
78
if(tokenAddr == address(0)){
79
balance = (address(this)).balance;
80
if(balance > 0){
81
(bool res, ) = owner.call.value(balance)("");
82
require(res);
83
}
84
}
85
else{
86
balance = IKIP7(tokenAddr).balanceOf(address(this));
87
if(balance > 0){
88
require(IKIP7(tokenAddr).transfer(owner, balance));
89
}
90
}
91
}
92
93
modifier onlyEcoPotVoting {
94
require(msg.sender == ecoPotVoting);
95
_;
96
}
97
98
function setEcoPot(address _ecoPot) public onlyEcoPotVoting {
99
require(ecoPot == address(0));
100
ecoPot = _ecoPot;
101
}
102
103
// ====================== Stat ====================================
104
105
function getEcoPotStat() public view returns (
106
address ecoPotContract, // airdrop distribution contract address
107
uint totalAmount, // Total amount of tokens to be distributed
108
uint blockAmount, // Amount of tokens to be distributed per block
109
uint distributableBlock, // Block number to airdrop start
110
uint endBlock, // Block number to airdrop end
111
uint distributed, // Amount of tokens distributed
112
uint remain // amount remaining in the contract
113
){
114
ecoPotContract = ecoPot;
115
116
EcoPotLike pot = EcoPotLike(ecoPot);
117
118
totalAmount = pot.totalAmount();
119
blockAmount = pot.amountPerBlock();
120
distributableBlock = pot.distributableBlock();
121
endBlock = pot.estimateEndBlock();
122
distributed = pot.getDistributedCurrent();
123
if(token == address(0)){
124
remain = (ecoPot).balance;
125
}
126
else{
127
remain = IKIP7(token).balanceOf(ecoPot);
128
}
129
}
130
131
// For Drops AirdropPool
132
function getAirdropStat() public view returns (
133
address ecoPotContract, // airdrop distribution contract address
134
uint totalAmount, // Total amount of tokens to be distributed
135
uint blockAmount, // Amount of tokens to be distributed per block
136
uint distributableBlock, // Block number to airdrop start
137
uint endBlock, // Block number to airdrop end
138
uint distributed, // Amount of tokens distributed
139
uint remain, // amount remaining in the contract
140
uint emptyUint, // return for airdropPool
141
address[] memory emptyAddressArr, // return for airdropPool
142
uint[] memory emptyUintArr // return for airdropPool
143
){
144
ecoPotContract = ecoPot;
145
146
EcoPotLike pot = EcoPotLike(ecoPot);
147
148
totalAmount = pot.totalAmount();
149
blockAmount = pot.amountPerBlock();
150
distributableBlock = pot.distributableBlock();
151
endBlock = pot.estimateEndBlock();
152
distributed = pot.getDistributedCurrent();
153
if(token == address(0)){
154
remain = (ecoPot).balance;
155
}
156
else{
157
remain = IKIP7(token).balanceOf(ecoPot);
158
}
159
160
emptyUint = 0;
161
emptyAddressArr = new address[](0);
162
emptyUintArr = new uint[](0);
163
}
164
165
// ===================== Airdrop method ===========================
166
///@param totalAmount : Total amount of tokens to be distributed
167
///@param blockAmount : Amount of tokens to be distributed per block
168
///@param startBlock : Block number to airdrop start
169
function initialize(uint totalAmount, uint blockAmount, uint startBlock) public payable onlyOwner {
170
require(totalAmount != 0);
171
require(blockAmount != 0);
172
require(startBlock >= block.number);
173
174
EcoPotLike pot = EcoPotLike(ecoPot);
175
require(pot.operator() == address(this));
176
require(!pot.isInitialized());
177
178
if(token == address(0)){
179
require((address(this)).balance >= totalAmount);
180
pot.initialize.value(totalAmount)(totalAmount, blockAmount, startBlock);
181
}
182
else {
183
require(IKIP7(token).transferFrom(owner, address(this), totalAmount));
184
require(IKIP7(token).approve(ecoPot, totalAmount));
185
pot.initialize(totalAmount, blockAmount, startBlock);
186
}
187
}
188
189
// Airdrop token deposit
190
///@param amount : Amount of airdrop token to deposit
191
function deposit(uint amount) public onlyOwner {
192
EcoPotLike pot = EcoPotLike(ecoPot);
193
194
require(pot.operator() == address(this));
195
require(pot.isAvailable());
196
require(amount != 0);
197
198
if(token == address(0)){
199
require((address(this)).balance >= amount);
200
pot.depositKlay.value(amount)();
201
}
202
else{
203
require(IKIP7(token).balanceOf(address(this)) >= amount);
204
require(IKIP7(token).approve(ecoPot, amount));
205
pot.depositToken(amount);
206
}
207
}
208
209
// Airdrop amount per block modification function
210
// The function is applied immediately from the called block
211
///@param blockAmount : airdrop block amount to change
212
function refixBlockAmount(uint blockAmount) public onlyOwner {
213
EcoPotLike pot = EcoPotLike(ecoPot);
214
215
require(pot.operator() == address(this));
216
require(pot.isAvailable());
217
require(blockAmount != 0);
218
219
pot.refixAmountPerBlock(blockAmount);
220
}
221
}
222
Copied!

2. Contract Submission

3. ValidOperator Request

  • Operator registration request ([email protected])
  • Set Valid Operator after confirming the contract distributed with Public EcoPotOperator Code