1

I'm trying to deploy contract using Mist on Mac OS X. It worked fine on testnet but when I try to do it on main net the transaction just hangs on

"Couldn't estimate gas, restoring to default parameters. Transaction is likely cheaper than the estimate"

I have deployed token contract using byte code and MEW before but in this contract I need to provide:

  • token address used as reward
  • token price
  • beneficiary address

and I just don't know how to do it using Remix and bytecode

Here's my contract

pragma solidity ^0.4.18;

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

contract Crowdsale {
address public beneficiary;
uint public amountRaised;
uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;

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

/**
 * Constructor function
 *
 * Setup the owner
 */
constructor(
    address ifSuccessfulSendTo,
    uint milietherCostOfEachToken,
    address addressOfTokenUsedAsReward
) public {
    beneficiary = ifSuccessfulSendTo;
    price = milietherCostOfEachToken * 0.001 ether;
    tokenReward = token(addressOfTokenUsedAsReward);
}

function () payable public {

uint amount = msg.value;
balanceOf[msg.sender] += amount;
amountRaised += amount;
tokenReward.transfer(msg.sender, amount * 10**18 / price);
emit FundTransfer(msg.sender, amount, true);

// Forward funds immediately to beneficiary
beneficiary.transfer(amount);
}
        }

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.