Last active
March 24, 2018 21:10
-
-
Save scyclow/a2459a61b6c40e2448c93a42f0b72fb5 to your computer and use it in GitHub Desktop.
ERC-20 Compliance
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 symbol = "FASTCASH"; | |
string public name = "FastCashMoneyPlus"; | |
mapping (address => uint) public balanceOf; | |
mapping (address => mapping (address => uint)) internal allowed; | |
event Approval(address indexed _owner, address indexed _spender, uint _value); | |
event Transfer(address indexed _from, address indexed _to, uint _value); | |
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 _from, | |
address _to, | |
uint _amount | |
) internal returns (bool success) { | |
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; | |
Transfer(msg.sender, _to, _amount); | |
return true; | |
} | |
function transfer(address _to, uint _amount) public returns (bool success) { | |
return _transfer(msg.sender, _to, _amount); | |
} | |
function transferFrom(address _from, address _to, uint _amount) external returns (bool success) { | |
require(allowed[_from][msg.sender] >= _amount); | |
bool _tranferSuccess = _transfer(_from, _to, _amount); | |
if (_tranferSuccess) { | |
allowed[_from][msg.sender] -= _amount; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function approve(address _spender, uint _value) external returns (bool success) { | |
allowed[msg.sender][_spender] = _value; | |
Approval(msg.sender, _spender, _value); | |
return true; | |
} | |
function allowance(address _owner, address _spender) external constant returns (uint remaining) { | |
return allowed[_owner][_spender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment