首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ropsten合同执行[恢复]

Ropsten合同执行[恢复]
EN

Ethereum用户
提问于 2018-04-09 13:09:33
回答 1查看 3K关注 0票数 0

有人能帮我,告诉我代码中哪里是问题所在吗?怎么解决这个问题?

https://ropsten.etherscan.io/tx/0xbd2079c12f90bb9396d79e7aeb5b5914472dd25c9e62ce36ffa85f6e88d7b594

有明显的错误吗?帮助不仅仅是appreciate.Robert

EN

回答 1

Ethereum用户

发布于 2018-04-09 22:19:54

当将以太发送到合同地址时,它将在您的合同中调用此函数:

代码语言:javascript
复制
function () payable whenNotPaused beforeDeadline afterStartTime saleNotClosed  {
    require(msg.value >= minContribution);

    // Update the sender's balance of wei contributed and the amount raised
    uint amount = msg.value;
    uint currentBalance = balanceOf[msg.sender];
    balanceOf[msg.sender] = currentBalance.add(amount);
    amountRaised = amountRaised.add(amount);

    // Compute the number of tokens to be rewarded to the sender
    // Note: it's important for this calculation that both wei
    // and PDT have the same number of decimal places (18)
    uint numTokens = amount.mul(rate);

    // Transfer the tokens from the crowdsale supply to the sender
    if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
        FundTransfer(msg.sender, amount, true);
        // Check if the funding goal or cap have been reached
        // TODO check impact on gas cost
        checkFundingGoal();
        checkFundingCap();
    }
    else {
        revert();
    }
}

如果下列任何一种方式之一,交易将被恢复:

  • 合同暂停
  • 最后期限后
  • 开始前时间
  • 出售已结束
  • 价值小于最低贡献。
  • 已达到供资目标或上限
票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/45158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档