是否可以将erc20Token、预售和ICO全部编码在一份合约中?

问题描述 投票:0回答:1

刚刚开始学习 Solidity 来帮助我的朋友。我想知道您是否可以并且应该在一份合同中包含以下所有内容。

  1. 创建 ERC20 代币
  2. 一段时间内使用某些白名单钱包进行预售
  3. 预售后启动 ICO 我可能完全错了,但我只是想学习。 预先感谢。

如果可能的话,我正在考虑使用 block.timestamp 来做到这一点。你也可以让我知道你对此的想法吗:)

ethereum solidity erc20 ico preorder
1个回答
0
投票

是的,你可以,

继承openzeppline ERC20代币合约并构建其余部分

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract YourToken is ERC20, Ownable {

    // properties
      - presaleStartDate
      - presaleEndDate
      - icoStartDate
      - icoEndDate
      - presalePrice
      - icoPrice
      - whitelistedAddresses


    constructor() ERC20("YourToken", "YRTKN") {
        _mint(msg.sender, 1000000 * 10 ** decimals()); 
    }

    // functions
     - whitelistAddress // use this one to set addresses
     - buyTokens // used to buy either presale or ico
     - setSaleRequirements // used to set all the above properties
     - withdrawSalesProfit // you can use this to withdraw money made from sale


}
  • 继续添加更多功能

虽然我不建议在一份合同中构建所有内容,但我希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.