Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. pragma solidity ^0.4.2;
  2.  
  3. contract MyToken {
  4. /* This creates an array with all balances */
  5. mapping (address => uint256) public balanceOf;
  6. string public name;
  7. string public symbol;
  8. uint8 public decimals;
  9.  
  10. event Transfer(address indexed from, address indexed to, uint256 value);
  11.  
  12. /* Initializes contract with initial supply tokens to the creator of the contract */
  13. function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) {
  14. balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
  15. name = tokenName; // Set the name for display purposes
  16. symbol = tokenSymbol; // Set the symbol for display purposes
  17. decimals = decimalUnits; // Amount of decimals for display purposes
  18. }
  19.  
  20. function transfer(address _to, uint256 _value) {
  21. /* Check if sender has balance and for overflows */
  22. if (balanceOf[msg.sender] < _value || balanceOf[_to] + _value < balanceOf[_to])
  23. throw;
  24.  
  25. /* Add and subtract new balances */
  26. balanceOf[msg.sender] -= _value;
  27. balanceOf[_to] += _value;
  28. /* Notify anyone listening that this transfer took place */
  29. Transfer(msg.sender, _to, _value);
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement