CrowdsaleToken.sol 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. pragma solidity ^0.4.8;
  2. import "./StandardToken.sol";
  3. /*
  4. * @title CrowdsaleToken
  5. *
  6. * @dev Simple ERC20 Token example, with crowdsale token creation
  7. * @dev IMPORTANT NOTE: do not use or deploy this contract as-is. It
  8. needs some changes to be production ready.
  9. */
  10. contract CrowdsaleToken is StandardToken {
  11. string public constant name = "CrowdsaleToken";
  12. string public constant symbol = "CRW";
  13. uint public constant decimals = 18;
  14. // replace with your fund collection multisig address
  15. address public constant multisig = 0x0;
  16. // 1 ether = 500 example tokens
  17. uint public constant PRICE = 500;
  18. /**
  19. * @dev A function that recieves ether and send the equivalent amount of
  20. the token to the msg.sender
  21. */
  22. function () payable {
  23. createTokens(msg.sender);
  24. }
  25. /**
  26. * @dev Function to create tokens and send to the specified address
  27. * @param recipient address The address which will recieve the new tokens.
  28. */
  29. function createTokens(address recipient) payable {
  30. if (msg.value == 0) {
  31. throw;
  32. }
  33. uint tokens = msg.value.mul(getPrice());
  34. totalSupply = totalSupply.add(tokens);
  35. balances[recipient] = balances[recipient].add(tokens);
  36. if (!multisig.send(msg.value)) {
  37. throw;
  38. }
  39. }
  40. /**
  41. * @dev replace this with any other price function
  42. * @return The price per unit of token.
  43. */
  44. function getPrice() constant returns (uint result) {
  45. return PRICE;
  46. }
  47. }