Im stuck with a crowdsale that needs to be deployed tomorrow! Already created token and now just want to crowdsale. So tried several examples- ethereum.org,zeppelin, github and all but they dont seem to give actual help where needed on address syntax of 3 address types Token address, contract address and receiver address of eth donations. Specifically I just want to know WHERE in the code (or compiler) to plug my token address and WHERE to place the contract address using solidity Compiler and where for reciever address.
Secondly, I think Im confused by the latter two addresses. Are these addresses generated or do I manually have to input them? Here's a link to the coin I want to fork. I want to keep it as simple as possible.
Thanks in advance
pragma solidity ^0.4.13;
contract ECToken {
function balanceOf(address _owner) constant returns (uint256);
function transfer(address _to, uint256 _value) returns (bool);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
interface Token {
function transfer(address _to, uint256 _value) returns (bool);
function totalSupply() constant returns (uint256 supply);
function balanceOf(address _owner) constant returns (uint256 balance);
}
contract TokenCrowdsale {
using SafeMath for uint256;
// Crowdsale details
address public beneficiary; //<---? Do I place a key string here 0x..... ?
address public creator; //<---? Do I place a key string here 0x..... ?
address public confirmedBy; //<---? Do I place a key string here 0x..... ?
uint256 public maxSupply = 15000;
bool public purchasingAllowed = false;
uint256 public totalSupplied = 0;
// Eth to token rate
uint256 public rate = 1200;
enum Stages {
PreSale, //0
InProgress, //1
Ended, //2
Withdrawn //3
}
Stages public stage = Stages.PreSale;
// deployed token
Token public deplToken;
// Invested balances
mapping (address => uint256) balances;
/**
* Throw if at stage other than current stage
*
* @param _stage expected stage to test for
*/
modifier atStage(Stages _stage) {
require(stage == _stage);
_;
}
/**
* Throw if sender is not beneficiary
*/
modifier onlyBeneficiary() {
require(beneficiary == msg.sender);
_;
}
/**
* Get balance of `_investor`
*
* @param _investor The address from which the balance will be retrieved
* @return The balance
*/
function balanceOf(address _investor) constant returns (uint256 balance) {
return balances[_investor];
}
function enablePurchasing() onlyBeneficiary atStage(Stages.PreSale) {
purchasingAllowed = true;
stage = Stages.InProgress;
}
function disablePurchasing() onlyBeneficiary atStage(Stages.InProgress) {
purchasingAllowed = false;
stage = Stages.Ended;
}
function enableNewPurchasing() onlyBeneficiary atStage(Stages.Withdrawn) {
purchasingAllowed = true;
stage = Stages.InProgress;
}
/**
* Constructor
*
* @param _tokenAddress The address of the token contact
* @param _beneficiary The address of the wallet for the beneficiary
* @param _creator The address of the wallet for the creator
*/
// Do I uncomment and define these parameters above in constructor area???
function TokenCrowdsale(address _tokenAddress, address _beneficiary, address _creator) {
deplToken = Token(_tokenAddress);
beneficiary = _beneficiary;
creator = _creator;
}
/**
* For testing purposes
*
* @return The beneficiary address
*/
function confirmBeneficiary() onlyBeneficiary {
confirmedBy = msg.sender;
}
event sendTokens(address indexed to, uint256 value);
/**
* Transfer raised amount to the beneficiary address
*/
function withdraw() onlyBeneficiary atStage(Stages.Ended) {
uint256 ethBalance = this.balance;
beneficiary.transfer(ethBalance);
stage = Stages.Withdrawn;
}
/**
* Receives Eth and issue tokens to the sender
*/
function () payable atStage(Stages.InProgress) {
require(purchasingAllowed);
if (msg.value == 0) { return; }
uint256 weiAmount = msg.value;
address investor = msg.sender;
uint256 received = weiAmount.div(10e7);
uint256 tokens = (received).mul(rate);
}
sendTokens(msg.sender, tokens);
deplToken.transfer(investor, tokens);
totalSupplied = (totalSupplied).add(tokens);
if (totalSupplied >= maxSupply) {
purchasingAllowed = false;
stage = Stages.Ended;
}
}
function tokensAvailable() constant returns (uint256) {
return deplToken.balanceOf(this);
}
function withdrawForeignTokens(address _tokenContract) onlyBeneficiary public returns (bool) {
ECToken token = ECToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(beneficiary, amount);
}
}