Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. pragma solidity ^0.4.18;
  2.  
  3. library SafeMath {
  4. function add(uint a, uint b) internal pure returns (uint c) {
  5. c = a + b;
  6. require(c >= a);
  7. }
  8. function sub(uint a, uint b) internal pure returns (uint c) {
  9. require(b <= a);
  10. c = a - b;
  11. }
  12. function mul(uint a, uint b) internal pure returns (uint c) {
  13. c = a * b;
  14. require(a == 0 || c / a == b);
  15. }
  16. function div(uint a, uint b) internal pure returns (uint c) {
  17. require(b > 0);
  18. c = a / b;
  19. }
  20. }
  21.  
  22. contract ERC20Interface {
  23. function totalSupply() public constant returns (uint);
  24. function balanceOf(address tokenOwner) public constant returns (uint balance);
  25. function transfer(address to, uint tokens) public returns (bool success);
  26. event Transfer(address indexed from, address indexed to, uint tokens);
  27. }
  28.  
  29. contract Owned {
  30. address public owner;
  31.  
  32. constructor() public {
  33. owner = msg.sender;
  34. }
  35.  
  36. modifier onlyOwner {
  37. require(msg.sender == owner);
  38. _;
  39. }
  40.  
  41. function transferOwnership(address _newOwner) public onlyOwner {
  42. owner = _newOwner;
  43. }
  44. }
  45.  
  46. contract ImperialToken is ERC20Interface, Owned {
  47. using SafeMath for uint;
  48.  
  49. string public symbol;
  50. string public name;
  51. uint8 public decimals;
  52. uint _totalSupply;
  53.  
  54. mapping(address => uint) balances;
  55.  
  56. constructor() public {
  57. symbol = "IMP";
  58. name = "IMPERIAL";
  59. decimals = 18;
  60. _totalSupply = 1000000000000 * 10**uint(decimals);
  61. balances[owner] = _totalSupply;
  62. emit Transfer(address(0), owner, _totalSupply);
  63. }
  64.  
  65. function totalSupply() public view returns (uint) {
  66. return _totalSupply.sub(balances[address(0)]);
  67. }
  68.  
  69. function balanceOf(address tokenOwner) public view returns (uint balance) {
  70. return balances[tokenOwner];
  71. }
  72.  
  73. function transfer(address to, uint tokens) public returns (bool success) {
  74. balances[msg.sender] = balances[msg.sender].sub(tokens);
  75. balances[to] = balances[to].add(tokens);
  76. emit Transfer(msg.sender, to, tokens);
  77. return true;
  78. }
  79. }
Add Comment
Please, Sign In to add comment