CrowdsaleToken.sol 770 B

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