I'm trying to test a token sale contract on the Ropsten test network but am having an issue. I am using Ethereum Wallet. I am following the guide at http://www.ethereum.org/crowdsale. I am getting this message:

enter image description here

The arguments for my crowdsale are the address of my test wallet, 25 minutes (arbitrary amount of minutes), and the address of my tokens.

Here is my crowdsale code:

pragma solidity ^0.4.18;

interface token {
    function transfer(address receiver, uint amount) public;

contract CoinCrowdsale {
    address public beneficiary;
    uint public amountRaised;
    uint public deadline;
    uint public price = 500 wei;
    uint public hardCap = 1000 wei; 
    uint public softCap = 500 wei;
    token public tokenReward;

    mapping(address => uint256) public balanceOf;

    bool softCapReached = false;
    bool hardCapReached = false;
    bool crowdsaleClosed = false;

    event GoalReached(address recipient, uint totalAmountRaised);
    event FundTransfer(address backer, uint amount, bool isContribution);

     * Constrctor function
     * Setup the owner
    function CoinCrowdsale (
        address Address,
        address benAddress,
        uint durationInMinutes
    ) public {
        beneficiary = benAddress;
        deadline = now + durationInMinutes * 1 minutes;
        tokenReward = token(Address);

     * Fallback function
     * The function without name is the default function that is called whenever anyone sends funds to a contract
    function () payable public {
      require(msg.value > 0.1 ether);
      uint amount = msg.value;
      balanceOf[msg.sender] += amount;
      amountRaised += amount;
      tokenReward.transfer(msg.sender, amount / price);
      FundTransfer(msg.sender, amount, true);
      if (amountRaised >= hardCap){
        hardCapReached = true;
        crowdsaleClosed = true;

    modifier afterDeadline() {
      if (now >= deadline || hardCapReached == true) _;

     * Check if goal was reached
     * Checks if the goal or time limit has been reached and ends the campaign
    function checkGoalReached() afterDeadline public {
      if (amountRaised >= softCap){
          softCapReached = true;
          GoalReached(beneficiary, amountRaised);
      crowdsaleClosed = true;

     * Withdraw the funds
     * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
     * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
     * the amount they contributed.
    function safeWithdrawal() afterDeadline public {
      if (!softCapReached) {
          uint amount = balanceOf[msg.sender];
          balanceOf[msg.sender] = 0;
          if (amount > 0) {
              if (msg.sender.send(amount)) {
                  FundTransfer(msg.sender, amount, false);
              } else {
                  balanceOf[msg.sender] = amount;

      if (softCapReached && beneficiary == msg.sender) {
        if (beneficiary.send(amountRaised)) {
          FundTransfer(beneficiary, amountRaised, false);
        } else {
          //If we fail to send the funds to beneficiary, unlock funders balance
          softCapReached = false;


I've tried putting it into remix and am getting a warning saying that it will require infinite gas - the same happens when I copy and paste the example crowdsale from the Ethereum site. How do I fix this / what is wrong?

  • 1
    What's the address of your contract? A couple guesses: did you pass the address of a valid ERC20 token address to the constructor? Did you transfer enough of those tokens over to the crowdsale contract before attempting your purchase? – smarx Dec 31 '17 at 22:03
  • @smarx, yeah that was it. I forgot to send tokens to the crowdsale contract. Had though putting the address was enough but it is not. Now I'm getting an issue where the amount of tokens is divided by 10^18 (it's treating the amount of ethereum as if it was in wei so it's a much smaller number). Thanks. – WMios Dec 31 '17 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.