Guest User

Untitled

a guest
Dec 16th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. pragma solidity ^0.4.4;
  2.  
  3. contract MyCoin {
  4.  
  5. string public name;
  6. string public symbol;
  7. uint8 public decimal;
  8. uint256 public totalSupply;
  9.  
  10. mapping(address => uint256) public balance;
  11.  
  12. event Transfer(address indexed _from, address _to, uint256 _value);
  13. event Burn(address indexed _caller, uint256 _value);
  14.  
  15. function MyCoin(string coinName, string sym, uint8 decimalPoint, uint256 initSupply){
  16.  
  17. name = coinName; // Name of your newly created coin
  18. symbol = sym; // Symbol of your newly created coin
  19. decimal = decimalPoint; // Define decimal point of your currency
  20. totalSupply = initSupply; // In start total supply will be same as initial supply
  21.  
  22. balance[msg.sender] = initSupply; // Will assign all the initial supply to creator of currency
  23. }
  24.  
  25. function transfer(address _to,uint256 _value) returns (bool){
  26.  
  27. if(_to == address(0x0)) revert(); // Check for valid _to address
  28. if(balance[msg.sender] < _value) revert(); // Check if sender has enough balance
  29.  
  30. balance[msg.sender] -= _value; // Subtract from the balance of sender
  31. balance[_to] += _value; // Add to the balance of receiver
  32.  
  33. Transfer(msg.sender,_to,_value); // Generate a transfer event for eventListeners and logging
  34. return true;
  35. }
  36.  
  37. function burn(uint256 _value) returns (bool){
  38.  
  39. if(balance[msg.sender] < _value) revert(); // Check if the caller has enough balance
  40. balance[msg.sender] -= _value; // Subtract value from caller's balance
  41. totalSupply -= _value; // Subtract value from total supply
  42. Burn(msg.sender,_value); // Generate a burn event for eventListeners and logging
  43. return true;
  44. }
  45.  
  46. function checkBalance() returns (uint256){
  47. return balance[msg.sender]; // Return the balance of caller
  48. }
  49.  
  50. function currencyDetails() returns (string coinName, string sym, uint8 decimalPoint, uint256 totSupply){
  51. coinName = name;
  52. sym = symbol;
  53. decimalPoint = decimal;
  54. totSupply = totalSupply;
  55. }
  56.  
  57. }
Add Comment
Please, Sign In to add comment