CrowdsaleToken.sol 792 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. pragma solidity ^0.4.4;
  2. import "./StandardToken.sol";
  3. /*
  4. * CrowdsaleToken
  5. *
  6. * Simple ERC20 Token example, with crowdsale token creation
  7. */
  8. contract CrowdsaleToken is StandardToken {
  9. string public name = "CrowdsaleToken";
  10. string public symbol = "CRW";
  11. uint public decimals = 18;
  12. // 1 ether = 500 example tokens
  13. uint PRICE = 500;
  14. function () payable {
  15. createTokens(msg.sender);
  16. }
  17. function createTokens(address recipient) payable {
  18. if (msg.value == 0) throw;
  19. uint tokens = safeMul(msg.value, getPrice());
  20. totalSupply = safeAdd(totalSupply, tokens);
  21. balances[recipient] = safeAdd(balances[recipient], tokens);
  22. }
  23. // replace this with any other price function
  24. function getPrice() constant returns (uint result){
  25. return PRICE;
  26. }
  27. }