Merge pull request #283 from OpenZeppelin/crowdsale

Add Crowdsale contracts
This commit is contained in:
Manuel Aráoz
2017-07-02 17:59:19 -03:00
committed by GitHub
22 changed files with 814 additions and 85 deletions

View File

@ -1,60 +0,0 @@
pragma solidity ^0.4.11;
import "./StandardToken.sol";
/**
* @title CrowdsaleToken
*
* @dev Simple ERC20 Token example, with crowdsale token creation
* @dev IMPORTANT NOTE: do not use or deploy this contract as-is. It needs some changes to be
* production ready.
*/
contract CrowdsaleToken is StandardToken {
string public constant name = "CrowdsaleToken";
string public constant symbol = "CRW";
uint256 public constant decimals = 18;
// replace with your fund collection multisig address
address public constant multisig = 0x0;
// 1 ether = 500 example tokens
uint256 public constant PRICE = 500;
/**
* @dev Fallback function which receives ether and sends the appropriate number of tokens to the
* msg.sender.
*/
function () payable {
createTokens(msg.sender);
}
/**
* @dev Creates tokens and send to the specified address.
* @param recipient The address which will recieve the new tokens.
*/
function createTokens(address recipient) payable {
if (msg.value == 0) {
throw;
}
uint256 tokens = msg.value.mul(getPrice());
totalSupply = totalSupply.add(tokens);
balances[recipient] = balances[recipient].add(tokens);
if (!multisig.send(msg.value)) {
throw;
}
}
/**
* @dev replace this with any other price function
* @return The price per unit of token.
*/
function getPrice() constant returns (uint256 result) {
return PRICE;
}
}

View File

@ -7,19 +7,15 @@ import '../lifecycle/Pausable.sol';
* Pausable token
*
* Simple ERC20 Token example, with pausable token creation
* Issue:
* https://github.com/OpenZeppelin/zeppelin-solidity/issues/194
* Based on code by BCAPtoken:
* https://github.com/BCAPtoken/BCAPToken/blob/5cb5e76338cc47343ba9268663a915337c8b268e/sol/BCAPToken.sol#L27
**/
contract PausableToken is StandardToken, Pausable {
function transfer(address _to, uint256 _value) whenNotPaused {
function transfer(address _to, uint _value) whenNotPaused {
super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused {
function transferFrom(address _from, address _to, uint _value) whenNotPaused {
super.transferFrom(_from, _to, _value);
}
}