Last active
March 24, 2018 21:11
-
-
Save scyclow/736bea1c45bb0dc14a1f51dde75b98f5 to your computer and use it in GitHub Desktop.
Buying Token contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
/* | |
Copyright 2017, FastCashMoneyPlus.biz | |
This contract is for educational purposes only, and is presented WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. | |
*/ | |
contract FastCashMoneyPlus { | |
uint public totalSupply; | |
uint256 public fastCashBank; | |
address public centralBanker; | |
uint public decimals = 18; | |
string public name = "FastCashMoneyPlus"; | |
mapping (address => uint) public balanceOf; | |
function FastCashMoneyPlus() { | |
totalSupply = 1000000 * 10 ** uint256(decimals); | |
fastCashBank = totalSupply; | |
centralBanker = msg.sender; | |
} | |
function weiToMoneyBucks(uint _wei) returns (uint) { | |
return _wei * 2; | |
} | |
function buy() payable returns (uint) { | |
uint _wei = msg.value; | |
uint _moneyBucks = weiToMoneyBucks(_wei); | |
require(_moneyBucks > 0); | |
require(fastCashBank >= _moneyBucks); | |
balanceOf[msg.sender] += _moneyBucks; | |
fastCashBank -= _moneyBucks; | |
centralBanker.transfer(msg.value); | |
return _moneyBucks; | |
} | |
function transfer(address _to, uint _amount) public returns (bool success) { | |
address _from = msg.sender; | |
require(_to != address(0)); | |
require(_to != address(this)); | |
require(_amount > 0); | |
require(balanceOf[_from] >= _amount); | |
require(balanceOf[_to] + _amount > balanceOf[_to]); | |
balanceOf[_from] -= _amount; | |
balanceOf[_to] += _amount; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment