CrowdsaleToken.sol 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. pragma solidity ^0.4.8;
  2. import "./StandardToken.sol";
  3. /*
  4. * CrowdsaleToken
  5. *
  6. * Simple ERC20 Token example, with crowdsale token creation
  7. * IMPORTANT NOTE: do not use or deploy this contract as-is.
  8. * It 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. function () payable {
  19. createTokens(msg.sender);
  20. }
  21. function createTokens(address recipient) payable {
  22. if (msg.value == 0) {
  23. throw;
  24. }
  25. uint tokens = safeMul(msg.value, getPrice());
  26. totalSupply = safeAdd(totalSupply, tokens);
  27. balances[recipient] = safeAdd(balances[recipient], tokens);
  28. if (!multisig.send(msg.value)) {
  29. throw;
  30. }
  31. }
  32. // replace this with any other price function
  33. function getPrice() constant returns (uint result) {
  34. return PRICE;
  35. }
  36. }