Addresses

ICO 合約地址轉移 關於

  • April 26, 2018

我正在使用此契約程式碼並想創建 ico 契約。但是當我創建合約程式碼並嘗試轉移 eth 時,我遇到了錯誤。我無法將乙太坊轉移到 ico 合約地址。

警告!合約執行過程中遇到的錯誤$$ Bad jump destination $$

你能幫助我嗎 ?

pragma solidity ^0.4.6;

import "./ABCToken.sol";
import "./SafeMath.sol";

ABCToken public ABCToken;

// Address of the founder of ABC.
address public founder = 0x3311111111111111111111111111111111111133;

// Address where all tokens created during ICO stage initially allocated
address public allocationAddress = 0x2111111111111111111111111111111111111111;

// Start date of the ICO
uint public startDate = 1524528001;  

// End date of the ICO
uint public endDate = 1535068801;  

// Token price without discount during the ICO stage
uint public baseTokenPrice = 10000000; // 0.001 ETH, considering 8 decimal places

// Number of tokens distributed to investors
uint public tokensDistributed = 0;

/*
*  Modifiers
*/
modifier onlyFounder() {
   // Only founder is allowed to do this action.
   if (msg.sender != founder) {
       throw;
   }
   _;
}

modifier minInvestment(uint investment) {
   // User has to send at least the ether value of one token.
   if (investment < baseTokenPrice) {
       throw;
   }
   _;
}

/// @dev Returns current bonus
function getCurrentBonus()
   public
   constant
   returns (uint)
{
   return getBonus(now);
}

/// @dev Returns bonus for the specific moment
/// @param timestamp Time of investment (in seconds)
function getBonus(uint timestamp)
   public
   constant
   returns (uint)
{   
   if (timestamp > endDate) {
       throw;
   }

   if (startDate > timestamp) {
       return 1499;  // 49.9%
   }

   uint icoDuration = timestamp - startDate;
   if (icoDuration >= 16 days) {
       return 1000;  // 0%
   } else if (icoDuration >= 9 days) {
       return 1125;  // 12.5%
   } else if (icoDuration >= 2 days) {
       return 1250;  // 25%
   } else {
       return 1499;  // 49.9%
   }
}

function calculateTokens(uint investment, uint timestamp)
   public
   constant
   returns (uint)
{
   // calculate discountedPrice
   uint discountedPrice = div(mul(baseTokenPrice, 1000), getBonus(timestamp));

   // Token count is rounded down. Sent ETH should be multiples of baseTokenPrice.
   return div(investment, discountedPrice);
}


/// @dev Issues tokens for users who made BTC purchases.
/// @param beneficiary Address the tokens will be issued to.
/// @param investment Invested amount in Wei
/// @param timestamp Time of investment (in seconds)
function fixInvestment(address beneficiary, uint investment, uint timestamp)
   external
   onlyFounder
   minInvestment(investment)
   returns (uint)
{   

   // Calculate number of tokens to mint
   uint tokenCount = calculateTokens(investment, timestamp);

   // Update fund's and user's balance and total supply of tokens.
   tokensDistributed = add(tokensDistributed, tokenCount);

   // Distribute tokens.
   if (!ABCToken.transferFrom(allocationAddress, beneficiary, tokenCount)) {
       // Tokens could not be issued.
       throw;
   }

   return tokenCount;
}

/// @dev Contract constructor
function ABCICO(address tokenAddress, address founderAddress) {
   // Set token address
   ABCToken = ABCToken(tokenAddress);

   // Set founder address
   founder = founderAddress;
}

/// @dev Fallback function
function () payable {
   throw;
}

}

我的假設是您唯一標記為payable的函式,即備份函式throws,因此拒絕了 eth 轉移。

從官方文件中查看這個Register合約並查看一個很好的範例,並簡要說明如何使用payable關鍵字。

好的,我更改了備份功能並解決了問題,但現在 Ico 合約無法向我轉移代幣。契約正在採取乙太坊機器人沒有轉移代幣。

IcoDuration 正在工作我在 +2 天期間。

引用自:https://ethereum.stackexchange.com/questions/46682