Guest User

Untitled

a guest
Oct 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. pragma solidity ^0.4.4;
  2.  
  3. contract StandardToken {
  4.  
  5. mapping (address => uint) public balanceOf;
  6.  
  7. event Transfer(address indexed _from, address indexed _to, uint256 _value);
  8.  
  9. function transfer(address _to, uint256 _value) public returns (bool success) {
  10. if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value > balanceOf[_to]) {
  11. balanceOf[msg.sender] -= _value;
  12. balanceOf[_to] += _value;
  13. emit Transfer(msg.sender, _to, _value);
  14. return true;
  15. } else { return false; }
  16. }
  17.  
  18. }
  19.  
  20. contract DFMtestCoin is StandardToken {
  21.  
  22. /* Public variables of the token */
  23.  
  24. string public name; // Token Name
  25. uint256 public decimals; // How many decimals to show.
  26. string public symbol; // Token identifier
  27. uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
  28. address public fundsWallet; // Where should the raised ETH go?
  29.  
  30. // This is a constructor function
  31. constructor () public {
  32. balanceOf[msg.sender] = 100000; // Give the creator all initial tokens.
  33. name = "DFMtestCoin"; // Set the name for display purposes
  34. decimals = 2; // Amount of decimals for display purposes
  35. symbol = "DFMcn"; // Set the symbol for display purposes
  36. unitsOneEthCanBuy = 1000; // Set the price of your token for the ICO
  37. fundsWallet = msg.sender; // The owner of the contract gets ETH
  38. }
  39.  
  40. // Fallback function executed when receiving ETH
  41. function() public payable {
  42.  
  43. uint256 amount = (msg.value * unitsOneEthCanBuy) / (1e18); // ETH to DFMcn
  44. require(balanceOf[fundsWallet] >= amount); // buying amount has to be smaller than the funds
  45.  
  46. balanceOf[fundsWallet] -= amount;
  47. balanceOf[msg.sender] += amount; // selling token amount to msg.sender
  48.  
  49. emit Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
  50.  
  51. //Transfer Ether to fundsWallet
  52. fundsWallet.transfer(msg.value);
  53. }
  54. }
Add Comment
Please, Sign In to add comment