Guest User

Untitled

a guest
Jun 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. pragma solidity ^0.4.24;
  2.  
  3. contract MemphisContract {
  4.  
  5. string public name = "Memphis";
  6. string public symbol = "MEM";
  7. // it's design how many times can i divide 1 token
  8. uint8 public decimals = 18;
  9. uint public totalSupply;
  10. uint public MemphisSupply = 5000000000;
  11. uint public buyPrice = 19555555;
  12. // creator will be the address of the contract's creator
  13. address public creator;
  14.  
  15. // This creates an array with all balances
  16. mapping (address => uint256) public balanceOf;
  17.  
  18. // This generates a public event on the blockchain that will notify clients
  19. event Transfer(address indexed from, address indexed to, uint256 value);
  20. event FundTransfer(address backer, uint amount, bool isContribution);
  21.  
  22.  
  23. /**
  24. * Constrctor function
  25. * Initializes contract with initial supply tokens to the creator of the contract
  26. */
  27. constructor() public {
  28. /*
  29. * We have 18 like deciamls so we must have (18 ^ 10) * MemphisSupply
  30. * Update total supply with the decimal amount
  31. */
  32. totalSupply = MemphisSupply * 10 ** uint256(decimals);
  33. balanceOf[msg.sender] = totalSupply; // Give NeroCoin Mint the total created tokens
  34. creator = msg.sender;
  35. }
  36.  
  37. /**
  38. * Internal transfer, only can be called by this contract
  39. */
  40. function _transfer(address _from, address _to, uint _value) internal {
  41. // Prevent transfer to 0x0 address. Use burn() instead
  42. require(_to != 0x0);
  43. // Check if the sender has enough
  44. require(balanceOf[_from] >= _value);
  45. // Check for overflows
  46. require(balanceOf[_to] + _value >= balanceOf[_to]);
  47. // Subtract from the sender
  48. balanceOf[_from] -= _value;
  49. // Add the same to the recipient
  50. balanceOf[_to] += _value;
  51. emit Transfer(_from, _to, _value);
  52. }
  53.  
  54. /**
  55. * Transfer tokens
  56. *
  57. * Send `_value` tokens to `_to` from your account
  58. *
  59. * @param _to The address of the recipient
  60. * @param _value the amount to send
  61. */
  62. function transfer(address _to, uint256 _value) public {
  63. _transfer(msg.sender, _to, _value);
  64. }
  65.  
  66.  
  67. /*
  68. * This function is call when ether send to the contract
  69. * @notice Buy tokens from contract by sending ether
  70. */
  71. uint public lastValue;
  72. function () payable internal {
  73. // The Memphis's token amount is calculate to be send to buyer
  74. lastValue = msg.value;
  75. uint amount = msg.value * buyPrice;
  76. // checks if it has enough to sell
  77. require(balanceOf[creator] >= amount);
  78. balanceOf[msg.sender] += amount;
  79. balanceOf[creator] -= amount;
  80. emit Transfer(creator, msg.sender, amount);
  81. creator.transfer(amount);
  82. }
  83.  
  84. }
Add Comment
Please, Sign In to add comment