tegarkurniawan

My Token

Sep 15th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. contract MyToken {
  2. string public name;
  3. string public symbol;
  4. uint8 public decimals;
  5. uint numContact;
  6. struct Contact{
  7. //address alamat;
  8. string name;
  9. string phone;
  10. }
  11. mapping (address => uint256) public balanceOf;
  12. mapping (uint => Contact) contacts;
  13.  
  14. function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) {
  15. balanceOf[msg.sender] = initialSupply;
  16. name = tokenName;
  17. symbol = tokenSymbol;
  18. decimals = decimalUnits;
  19. }
  20.  
  21. function transfer(address _to, uint256 _value) {
  22.  
  23. if (balanceOf[msg.sender] < _value || balanceOf[_to] + _value < balanceOf[_to])
  24. throw;
  25. balanceOf[msg.sender] -= _value;
  26. balanceOf[_to] += _value;
  27. }
  28.  
  29. function saveContact(string _name, string _phone) returns (uint ContactID){
  30. ContactID = numContact++;
  31. Contact c = contacts[ContactID];
  32. //c.alamat = _alamat;
  33. c.name = _name;
  34. c.phone = _phone;
  35. }
  36. }
Add Comment
Please, Sign In to add comment