【问题标题】:Security audit for Token Distribution ICO代币分发 ICO 的安全审计
【发布时间】:2017-10-04 09:44:26
【问题描述】:

这是我们的 MEG-Token-Distribution 1.0。我们需要某人的帮助。 Link for full code.

我们如何访问 mint 功能(令牌所有者是 EggithCrowdsale)?

我们如何根据 msg.value 更改汇率(如果另一个价格 > 20 ETH)?

contract EggithToken is MintableToken {
    string public constant name = "EggithToken";
    string public constant symbol = "MEG";
    uint8 public constant decimals = 18;
}

contract EggithCrowdsale is Crowdsale {
    function EggithCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet)
         Crowdsale(_startTime, _endTime, _rate, _wallet)
    {
    }

    // creates the token to be sold. 
    // override this method to have crowdsale of a specific mintable token.
    function createTokenContract() internal returns (MintableToken) {
        return new EggithToken();
    }
}

【问题讨论】:

    标签: blockchain ethereum solidity


    【解决方案1】:

    “我们如何根据 msg.value 改变汇率(如果另一个价格 > 20 ETH)?”

       uint public constant regularPrice = 100;
       uint public constant moreThan20EthContributionPrice = 75;
    
       function () payable { 
       //fallback function that is called when ETH is sent to contract
    
       ... some code ...
    
       uint price = calculatePrice();
    
       ... some code ...
    
        }
    
        function calculatePrice() internal constant returns (uint) {
            if (msg.value > 20 ether) return moreThan20EthContributionPrice;
            return regularPrice;
       }
    

    【讨论】:

    猜你喜欢
    • 2011-10-12
    • 2012-11-19
    • 2021-04-14
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 2011-06-04
    相关资源
    最近更新 更多