Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.4;
- contract StandardToken {
- mapping (address => uint) public balanceOf;
- event Transfer(address indexed _from, address indexed _to, uint256 _value);
- function transfer(address _to, uint256 _value) public returns (bool success) {
- if (balanceOf[msg.sender] >= _value && balanceOf[_to] + _value > balanceOf[_to]) {
- balanceOf[msg.sender] -= _value;
- balanceOf[_to] += _value;
- emit Transfer(msg.sender, _to, _value);
- return true;
- } else { return false; }
- }
- }
- contract DFMtestCoin is StandardToken {
- /* Public variables of the token */
- string public name; // Token Name
- uint256 public decimals; // How many decimals to show.
- string public symbol; // Token identifier
- uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH?
- address public fundsWallet; // Where should the raised ETH go?
- // This is a constructor function
- constructor () public {
- balanceOf[msg.sender] = 100000; // Give the creator all initial tokens.
- name = "DFMtestCoin"; // Set the name for display purposes
- decimals = 2; // Amount of decimals for display purposes
- symbol = "DFMcn"; // Set the symbol for display purposes
- unitsOneEthCanBuy = 1000; // Set the price of your token for the ICO
- fundsWallet = msg.sender; // The owner of the contract gets ETH
- }
- // Fallback function executed when receiving ETH
- function() public payable {
- uint256 amount = (msg.value * unitsOneEthCanBuy) / (1e18); // ETH to DFMcn
- require(balanceOf[fundsWallet] >= amount); // buying amount has to be smaller than the funds
- balanceOf[fundsWallet] -= amount;
- balanceOf[msg.sender] += amount; // selling token amount to msg.sender
- emit Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain
- //Transfer Ether to fundsWallet
- fundsWallet.transfer(msg.value);
- }
- }
Add Comment
Please, Sign In to add comment