ICOdefi
ICO
how to deploy:
-
choose an erc20 or deploy
PICO
-
deploy
ico
, set purchase token address -> pico -
deploy
TICO
, set addressico
-
into
ico
set functiontargetIco(tico)
-
into
ico
run functionrelease
-
mock erc20 (PICO) : block explorer - purchase token
-
mock ico token (TICO) : block explorer - ico token
-
ICO : block explorer
-
dont forget to approve
ico
address from purchasedpico
-
you can change amount of
tico
inconstructor
for ico
Review
- Start
function release() public onlyOwner {
require(!isStart, "ico has been run");
require(setup == true, "target ico not set yet");
isStart = true;
end = block.timestamp + duration;
}
- Claim
function claim(uint256 amount) public payable returns (bool _success, address _holder) {
require(isStart, "when? after run before end!");
require(block.timestamp < end, "finished, thanks for your support");
require(tokenPurchase.balanceOf(msg.sender) >= amount * price);
if(holder[msg.sender] + amount <= maxPurchase) {
require(tokenPurchase.approve(admin, amount * price)); // run by ethersjs as alternative this line of code
// same value of 2 tokens -> amount * price <- like a wrapped :)
// we change here: amount * price --> function setValue(....
require(tokenPurchase.transferFrom(msg.sender, admin, amount * price));
require(counter < checker, "amazing! holder full");
holder[msg.sender] += amount;
_success = true;
_holder = msg.sender;
holders[counter] = msg.sender;
counter++;
tokenIco.transfer(msg.sender, amount * 10 ** decimal);
// tokenIco.transferFrom(address(this), msg.sender, amount * 10 ** decimal);
emit Claim(msg.sender, amount, block.timestamp);
} else {
_success = false;
_holder = address(0);
}
wd();
}