diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..396a023 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Token_BFA/test.sol diff --git a/Addresses.sol b/Addresses.sol index a1a9448..ef0ace6 100644 --- a/Addresses.sol +++ b/Addresses.sol @@ -1,11 +1,11 @@ -pragma solidity ^0.4.0; - -library Addresses { - function isContract(address _base) internal constant returns (bool) { - uint codeSize; - assembly { - codeSize := extcodesize(_base) - } - return codeSize > 0; - } -} +pragma solidity ^0.4.0; + +library Addresses { + function isContract(address _base) internal constant returns (bool) { + uint codeSize; + assembly { + codeSize := extcodesize(_base) + } + return codeSize > 0; + } +} diff --git a/Crowdsale.sol b/Crowdsale.sol index 76017cc..52cad64 100644 --- a/Crowdsale.sol +++ b/Crowdsale.sol @@ -1,90 +1,90 @@ -pragma solidity ^0.4.0; - -import "./ERC223ReceivingContract.sol"; -import "./SafeMath.sol"; -import "./ERC20.sol"; -import "./Token.sol"; - -contract Crowdsale is ERC223ReceivingContract { - - using SafeMath for uint; - - Token private _token; - - uint private _start; - uint private _end; - - uint private _price; - uint private _limit; - uint private _available; - - mapping (address => uint) private _limits; - - event Buy(address beneficiary, uint amount); - - modifier available() { - require(_available > 0); - require(block.number >= _start && block.number < _end); - _; - } - - modifier isToken() { - require(msg.sender == address(_token)); - _; - } - - modifier valid(address to, uint amount) { - assert(amount > 0); - amount = amount.div(_price); - assert(_limit >= amount); - assert(_limit >= _limits[to].add(amount)); - _; - } - - function Crowdsale(address token, uint start, uint end, uint price, uint limit) - public { - _token = Token(token); - _start = start; - _end = end; - _price = price; - _limit = limit; - } - - function () - public - payable { - // Not enough gas for the transaction so prevent users from sending ether - revert(); - } - - function buy() - public - payable { - return buyFor(msg.sender); - } - - function buyFor(address beneficiary) - public - available - valid(beneficiary, msg.value) - payable { - uint amount = msg.value.div(_price); - _token.transfer(beneficiary, amount); - _available = _available.sub(amount); - _limits[beneficiary] = _limits[beneficiary].add(amount); - Buy(beneficiary, amount); - } - - function tokenFallback(address, uint _value, bytes) - isToken - public { - _available = _available.add(_value); - } - - function availableBalance() - view - public - returns (uint) { - return _available; - } -} +pragma solidity ^0.4.0; + +import "./ERC223ReceivingContract.sol"; +import "./SafeMath.sol"; +import "./ERC20.sol"; +import "./Token.sol"; + +contract Crowdsale is ERC223ReceivingContract { + + using SafeMath for uint; + + Token private _token; + + uint private _start; + uint private _end; + + uint private _price; + uint private _limit; + uint private _available; + + mapping (address => uint) private _limits; + + event Buy(address beneficiary, uint amount); + + modifier available() { + require(_available > 0); + require(block.number >= _start && block.number < _end); + _; + } + + modifier isToken() { + require(msg.sender == address(_token)); + _; + } + + modifier valid(address to, uint amount) { + assert(amount > 0); + amount = amount.div(_price); + assert(_limit >= amount); + assert(_limit >= _limits[to].add(amount)); + _; + } + + function Crowdsale(address token, uint start, uint end, uint price, uint limit) + public { + _token = Token(token); + _start = start; + _end = end; + _price = price; + _limit = limit; + } + + function () + public + payable { + // Not enough gas for the transaction so prevent users from sending ether + revert(); + } + + function buy() + public + payable { + return buyFor(msg.sender); + } + + function buyFor(address beneficiary) + public + available + valid(beneficiary, msg.value) + payable { + uint amount = msg.value.div(_price); + _token.transfer(beneficiary, amount); + _available = _available.sub(amount); + _limits[beneficiary] = _limits[beneficiary].add(amount); + Buy(beneficiary, amount); + } + + function tokenFallback(address, uint _value, bytes) + isToken + public { + _available = _available.add(_value); + } + + function availableBalance() + view + public + returns (uint) { + return _available; + } +} diff --git a/ERC20.sol b/ERC20.sol index 87ecc9d..4987856 100644 --- a/ERC20.sol +++ b/ERC20.sol @@ -1,8 +1,8 @@ -pragma solidity ^0.4.0; - -interface ERC20 { - function transferFrom(address _from, address _to, uint _value) public returns (bool); - function approve(address _spender, uint _value) public returns (bool); - function allowance(address _owner, address _spender) public view returns (uint); - event Approval(address indexed _owner, address indexed _spender, uint _value); -} +pragma solidity ^0.4.0; + +interface ERC20 { + function transferFrom(address _from, address _to, uint _value) public returns (bool); + function approve(address _spender, uint _value) public returns (bool); + function allowance(address _owner, address _spender) public view returns (uint); + event Approval(address indexed _owner, address indexed _spender, uint _value); +} diff --git a/ERC223.sol b/ERC223.sol index 7f09792..c8b8cf5 100644 --- a/ERC223.sol +++ b/ERC223.sol @@ -1,6 +1,6 @@ -pragma solidity ^0.4.0; - -interface ERC223 { - function transfer(address _to, uint _value, bytes _data) public returns (bool); - event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); -} +pragma solidity ^0.4.0; + +interface ERC223 { + function transfer(address _to, uint _value, bytes _data) public returns (bool); + event Transfer(address indexed from, address indexed to, uint value, bytes indexed data); +} diff --git a/ERC223ReceivingContract.sol b/ERC223ReceivingContract.sol index 264c6b9..a553dcb 100644 --- a/ERC223ReceivingContract.sol +++ b/ERC223ReceivingContract.sol @@ -1,5 +1,5 @@ -pragma solidity ^0.4.0; - -contract ERC223ReceivingContract { - function tokenFallback(address _from, uint _value, bytes _data) public; -} +pragma solidity ^0.4.0; + +contract ERC223ReceivingContract { + function tokenFallback(address _from, uint _value, bytes _data) public; +} diff --git a/MyToken.sol b/MyToken.sol index 8fb5001..03626c7 100644 --- a/MyToken.sol +++ b/MyToken.sol @@ -1,110 +1,110 @@ -pragma solidity ^0.4.0; - -import "./Token.sol"; -import "./ERC20.sol"; -import "./ERC223.sol"; -import "./ERC223ReceivingContract.sol"; -import "./SafeMath.sol"; -import "./Addresses.sol"; - -contract MyToken is Token("MFT", "My Token", 0, 10000), ERC20, ERC223 { - - using SafeMath for uint; - using Addresses for address; - - function MyToken() - public { - _balanceOf[msg.sender] = _totalSupply; - } - - function totalSupply() - public - view - returns (uint) { - return _totalSupply; - } - - function balanceOf(address _addr) - public - view - returns (uint) { - return _balanceOf[_addr]; - } - - function transfer(address _to, uint _value) - public - returns (bool) { - return transfer(_to, _value, ""); - } - - function transfer(address _to, uint _value, bytes _data) - public - returns (bool) { - if (_value > 0 && - _value <= _balanceOf[msg.sender]) { - - if (_to.isContract()) { - ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); - _contract.tokenFallback(msg.sender, _value, _data); - } - - _balanceOf[msg.sender] = _balanceOf[msg.sender].sub(_value); - _balanceOf[_to] = _balanceOf[_to].add(_value); - - return true; - } - return false; - } - - function transferFrom(address _from, address _to, uint _value) - public - returns (bool) { - return transferFrom(_from, _to, _value, ""); - } - - function transferFrom(address _from, address _to, uint _value, bytes _data) - public - returns (bool) { - if (_allowances[_from][msg.sender] > 0 && - _value > 0 && - _allowances[_from][msg.sender] >= _value && - _balanceOf[_from] >= _value) { - - _allowances[_from][msg.sender] -= _value; - - if (_to.isContract()) { - ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); - _contract.tokenFallback(msg.sender, _value, _data); - } - - _balanceOf[_from] = _balanceOf[_from].sub(_value); - _balanceOf[_to] = _balanceOf[_to].add(_value); - - Transfer(_from, _to, _value); - - return true; - } - return false; - } - - function approve(address _spender, uint _value) - public - returns (bool) { - if (_balanceOf[msg.sender] >= _value) { - _allowances[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); - return true; - } - return false; - } - - function allowance(address _owner, address _spender) - public - view - returns (uint) { - if (_allowances[_owner][_spender] < _balanceOf[_owner]) { - return _allowances[_owner][_spender]; - } - return _balanceOf[_owner]; - } -} +pragma solidity ^0.4.0; + +import "./Token.sol"; +import "./ERC20.sol"; +import "./ERC223.sol"; +import "./ERC223ReceivingContract.sol"; +import "./SafeMath.sol"; +import "./Addresses.sol"; + +contract MyToken is Token("BFA", "BFA Token", 8, 1000000000), ERC20, ERC223 { + + using SafeMath for uint; + using Addresses for address; + + function MyToken() + public { + _balanceOf[msg.sender] = _totalSupply; + } + + function totalSupply() + public + view + returns (uint) { + return _totalSupply; + } + + function balanceOf(address _addr) + public + view + returns (uint) { + return _balanceOf[_addr]; + } + + function transfer(address _to, uint _value) + public + returns (bool) { + return transfer(_to, _value, ""); + } + + function transfer(address _to, uint _value, bytes _data) + public + returns (bool) { + if (_value > 0 && + _value <= _balanceOf[msg.sender]) { + + if (_to.isContract()) { + ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); + _contract.tokenFallback(msg.sender, _value, _data); + } + + _balanceOf[msg.sender] = _balanceOf[msg.sender].sub(_value); + _balanceOf[_to] = _balanceOf[_to].add(_value); + + return true; + } + return false; + } + + function transferFrom(address _from, address _to, uint _value) + public + returns (bool) { + return transferFrom(_from, _to, _value, ""); + } + + function transferFrom(address _from, address _to, uint _value, bytes _data) + public + returns (bool) { + if (_allowances[_from][msg.sender] > 0 && + _value > 0 && + _allowances[_from][msg.sender] >= _value && + _balanceOf[_from] >= _value) { + + _allowances[_from][msg.sender] -= _value; + + if (_to.isContract()) { + ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); + _contract.tokenFallback(msg.sender, _value, _data); + } + + _balanceOf[_from] = _balanceOf[_from].sub(_value); + _balanceOf[_to] = _balanceOf[_to].add(_value); + + Transfer(_from, _to, _value); + + return true; + } + return false; + } + + function approve(address _spender, uint _value) + public + returns (bool) { + if (_balanceOf[msg.sender] >= _value) { + _allowances[msg.sender][_spender] = _value; + Approval(msg.sender, _spender, _value); + return true; + } + return false; + } + + function allowance(address _owner, address _spender) + public + view + returns (uint) { + if (_allowances[_owner][_spender] < _balanceOf[_owner]) { + return _allowances[_owner][_spender]; + } + return _balanceOf[_owner]; + } +} diff --git a/README.md b/README.md index 9d64fbe..a5b6e50 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# bfa v0.1.0 - Blockchain for Art -Using Blockchain in Art. This project is one of sub projects of OBORchain. +# bfa v0.1.0 - Blockchain for Art +Using Blockchain in Art. This project is one of sub projects of OBORchain. +
www.oborchain.org +
www.artnetwork.io diff --git a/SafeMath.sol b/SafeMath.sol index 027167c..d63f9b0 100644 --- a/SafeMath.sol +++ b/SafeMath.sol @@ -1,35 +1,35 @@ -pragma solidity ^0.4.0; - -library SafeMath { - function sub(uint _base, uint _value) - internal - pure - returns (uint) { - assert(_value <= _base); - return _base - _value; - } - - function add(uint _base, uint _value) - internal - pure - returns (uint _ret) { - _ret = _base + _value; - assert(_ret >= _base); - } - - function div(uint _base, uint _value) - internal - pure - returns (uint) { - assert(_value > 0 && (_base % _value) == 0); - return _base / _value; - } - - function mul(uint _base, uint _value) - internal - pure - returns (uint _ret) { - _ret = _base * _value; - assert(0 == _base || _ret / _base == _value); - } -} +pragma solidity ^0.4.0; + +library SafeMath { + function sub(uint _base, uint _value) + internal + pure + returns (uint) { + assert(_value <= _base); + return _base - _value; + } + + function add(uint _base, uint _value) + internal + pure + returns (uint _ret) { + _ret = _base + _value; + assert(_ret >= _base); + } + + function div(uint _base, uint _value) + internal + pure + returns (uint) { + assert(_value > 0 && (_base % _value) == 0); + return _base / _value; + } + + function mul(uint _base, uint _value) + internal + pure + returns (uint _ret) { + _ret = _base * _value; + assert(0 == _base || _ret / _base == _value); + } +} diff --git a/Token.sol b/Token.sol index 46d70e6..84f8e9f 100644 --- a/Token.sol +++ b/Token.sol @@ -1,52 +1,52 @@ -pragma solidity ^0.4.0; - -contract Token { - - string internal _symbol; - string internal _name; - - uint8 internal _decimals; - uint internal _totalSupply; - - mapping (address => uint) internal _balanceOf; - mapping (address => mapping (address => uint)) internal _allowances; - - function Token(string symbol, string name, uint8 decimals, uint totalSupply) public { - _symbol = symbol; - _name = name; - _decimals = decimals; - _totalSupply = totalSupply; - } - - function name() - public - view - returns (string) { - return _name; - } - - function symbol() - public - view - returns (string) { - return _symbol; - } - - function decimals() - public - view - returns (uint8) { - return _decimals; - } - - function totalSupply() - public - view - returns (uint) { - return _totalSupply; - } - - function balanceOf(address _addr) public view returns (uint); - function transfer(address _to, uint _value) public returns (bool); - event Transfer(address indexed _from, address indexed _to, uint _value); -} +pragma solidity ^0.4.0; + +contract Token { + + string internal _symbol; + string internal _name; + + uint8 internal _decimals; + uint internal _totalSupply; + + mapping (address => uint) internal _balanceOf; + mapping (address => mapping (address => uint)) internal _allowances; + + function Token(string symbol, string name, uint8 decimals, uint totalSupply) public { + _symbol = symbol; + _name = name; + _decimals = decimals; + _totalSupply = totalSupply; + } + + function name() + public + view + returns (string) { + return _name; + } + + function symbol() + public + view + returns (string) { + return _symbol; + } + + function decimals() + public + view + returns (uint8) { + return _decimals; + } + + function totalSupply() + public + view + returns (uint) { + return _totalSupply; + } + + function balanceOf(address _addr) public view returns (uint); + function transfer(address _to, uint _value) public returns (bool); + event Transfer(address indexed _from, address indexed _to, uint _value); +} diff --git a/Token_BFA/Addresses.sol b/Token_BFA/Addresses.sol new file mode 100644 index 0000000..5e5aa6d --- /dev/null +++ b/Token_BFA/Addresses.sol @@ -0,0 +1,11 @@ +pragma solidity ^0.4.21; + +library Addresses { + function isContract(address _base) internal view returns (bool) { + uint codeSize; + assembly { + codeSize := extcodesize(_base) + } + return codeSize > 0; + } +} \ No newline at end of file diff --git a/Token_BFA/BFACrowdsale.sol b/Token_BFA/BFACrowdsale.sol new file mode 100644 index 0000000..2578660 --- /dev/null +++ b/Token_BFA/BFACrowdsale.sol @@ -0,0 +1,198 @@ +pragma solidity ^0.4.21; + +import "./SafeMath.sol"; + +interface BFAToken { + + function transfer (address receiver, uint256 amount); +} + + + + +contract BFACrowdsale{ + + using SafeMath for uint; + + //contract owner msg.sender + address _owner; + + //BFAToken.sol address (must be deployed first) + BFAToken _tokenReward; + + //if crowdsale ended and funding goal reached + bool public _crowdsaleClosed = false; + bool public _fundingGoalReached = false; + + + //available token balance + uint256 public _available; + + //amount raised in total eth + uint256 public _amountRaised; + uint256 public _fundingGoal = 19000 * 1 ether; + uint8 public _fundingLevel; + + //early sale 10% off + bool public _earlySale = true; + uint16 public _earlySaleRate = 12000; + uint16 public _normalRate = 10000; + uint256 public _saleEndTime = now + 7 minutes; //end sale after 7 minutes change to days after testing + + //minimum eth purcahse of token + uint256 public _minEthPerToken = 10000000000000000; //each purchase must be greater than 0.01 eth + + //start time and end time of crowdsale + uint256 public _start; //can remove this + uint256 public _end; + + //limited allowance for purchase of token per address/user + mapping (address => uint) private _limits; + + //eth balance in case funding goal is not reached + mapping ( address => uint256) public _ethUserBalance; //check see if we send each user their eth balance + //in case we reach end of crowdsale without funding goal reached do we need to pay gas for each + //user and if so the total balance will be reduced per transfer and we will miss some balance how to fix that???? + //* very important above statement */ + + //check reentrance attack + //add burn function for msg.sender + //add manual eth fund transfer after level 1 goal is reached by msg.sender + //add function for msg.sender(owner of contract) to be able to take back tokens lost to contracts + + event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Approval(address indexed _owner, address indexed _spender, uint256 _value); + event Buy(address beneficiary, uint amount); //put events in another file + event GoalReached( address recipient, uint256 totalAmountRaised); + event FundTransfer(address backer, uint256 amount, bool isContribution); + + modifier isToken() { + require(msg.sender == address(_tokenReward)); //recheck this + _; + } + + + function BFACrowdsale(address addressOfTokenUsedAsReward) public { + _owner = msg.sender; + _tokenReward = BFAToken(addressOfTokenUsedAsReward); + _start = now; + _end = now + 31 days; + } + + + +//Initiate CrowdSale + + function tokenFallback(address, uint _value, bytes) isToken public { + _available = _available.add(_value); + } + + + //uint256 public ethRaised; + //1. disable _earlySale after one week where to put logic? 2. add limited buying too + function () payable public{ + require(msg.value > _minEthPerToken); + require(!_crowdsaleClosed); + require ((msg.value/(1 ether)) <= _available); + uint16 _tempPrice; + if(_earlySale && now > _saleEndTime) + _earlySale = false; + + if(_earlySale) //1. disable _earlySale after one week where to put logic? 2. add limited buying too + _tempPrice = _earlySaleRate; + else + _tempPrice = _normalRate; + + uint256 amount = msg.value; + _available = _available.sub((amount/(1 ether))); + _ethUserBalance[msg.sender] += amount; + _amountRaised += (amount/(1 ether)); + _tokenReward.transfer(msg.sender, (amount/(1 ether)) * _tempPrice); + emit Transfer (address(this), msg.sender, (amount/(1 ether))); + + } + + function buy() public payable { + return buyFor(msg.sender); + } + + function buyFor(address beneficiary) public //available //valid(beneficiary, msg.value) + payable { + require(msg.value > _minEthPerToken); + require(!_crowdsaleClosed); + require ((msg.value/(1 ether)) <= _available); + uint16 _tempPrice; + if(_earlySale) //1. disable _earlySale after one week where to put logic? 2. add limited buying too + _tempPrice = _earlySaleRate; + else + _tempPrice = _normalRate; + + uint256 amount = msg.value; + _available = _available.sub((amount/(1 ether))); + _ethUserBalance[msg.sender] += amount; + _amountRaised += (amount/(1 ether)); + _tokenReward.transfer(beneficiary, (amount/(1 ether))* _tempPrice); + emit Transfer (address(this), beneficiary, (amount/(1 ether))); + } + + function availableBalance() + view + public + returns (uint) { + return _available; + } + + + + modifier afterDeadline() { + require( now > _end); + _; } + + + function checkGoalReached() afterDeadline public { + + if( _amountRaised >= _fundingGoal ) + { + _fundingGoalReached = true; + emit GoalReached (_owner, _amountRaised); + } + _crowdsaleClosed = true; + } + + + function safeWithdrawal() afterDeadline public { + + if(!_fundingGoalReached) + { + uint256 _amount = _ethUserBalance[msg.sender]; + _ethUserBalance[msg.sender] = 0; + + if( _amount > 0) + { + if(msg.sender.send(_amount)) + { + emit FundTransfer(msg.sender, _amount, false); + } + else { + _ethUserBalance[msg.sender] = _amount; + } + + } + } + + if( _fundingGoalReached && _owner == msg.sender) + { + if(_owner.send(_amountRaised)){ + emit FundTransfer(_owner, _amountRaised, false); + } + else{ + _fundingGoalReached = false; + } + } + } + + + + + +} \ No newline at end of file diff --git a/Token_BFA/BFAToken.sol b/Token_BFA/BFAToken.sol new file mode 100644 index 0000000..7861a0a --- /dev/null +++ b/Token_BFA/BFAToken.sol @@ -0,0 +1,126 @@ +pragma solidity ^0.4.21; + +import "./SafeMath.sol"; +import "./ERC20.sol"; +import "./Addresses.sol"; + + +interface ERC223ReceivingContract { + function tokenFallback(address _from, uint _value, bytes _data) public; +} + +contract BFAToken is ERC20{ + + //Using external libraries + using SafeMath for uint; + using Addresses for address; + + //internal variables + string internal _symbol; + string internal _name; + + uint8 internal _decimals; + uint256 internal _totalSupply; + + //mapping for user token balance, ethereum balance (in case we cant reach goal), and allowance for withdrawal by third party + mapping (address => uint256) internal _tokenBalance; + mapping (address => mapping (address => uint256)) internal _allowances; + mapping (address => uint256) internal _ethBalance; + + function BFAToken (string symbol, string name, uint8 decimals, uint256 totalSupply ) public { + + _symbol = symbol; + _name = name; + _decimals = decimals; + _totalSupply = totalSupply; + _tokenBalance[msg.sender] = _totalSupply; + + } + + function name() + public view + returns (string){ + return _name; + } + + function symbol() + public view returns (string){ + return _symbol; + } + + function decimals() + public view returns (uint8){ + return _decimals; + } + + function totalSupply() + public view returns (uint256){ + return _totalSupply; + } + + + function balanceOf(address _owner) public view returns (uint256){ + return _tokenBalance[_owner]; + } + + function approve(address _spender, uint256 _value) public returns (bool){ + + if (_tokenBalance[msg.sender] >= _value) + { + _allowances[msg.sender][_spender] = _value; + emit Approval (msg.sender, _spender, _value); + return true; + } + return false; + + } + + + function allowance(address _owner, address _spender) public view returns (uint256){ + + return _allowances[_owner][_spender]; + } + + + //recheck function here + function _transfer(address _from, address _to, uint256 _value) internal{ + + require(_to != 0x0); + require(_tokenBalance[_from] >= _value); + require(_tokenBalance[_to] + _value >= _tokenBalance[_to]); + + if (_to.isContract()) { + ERC223ReceivingContract _contract = ERC223ReceivingContract(_to); + _contract.tokenFallback(_from, _value, "_data"); //check these 2 lines to make sure error free + } + + uint256 _previousBalance = _tokenBalance[_from] + _tokenBalance[_to]; + + _tokenBalance[_from] = _tokenBalance[_from].sub(_value); + _tokenBalance[_to] = _tokenBalance[_to].add(_value); + emit Transfer(_from, _to, _value); + assert(_tokenBalance[_from] + _tokenBalance[_to] == _previousBalance); + + } + //recheck above function + + function transfer(address _to, uint256 _value) public { + _transfer(msg.sender, _to, _value); + } + + //recheck below function + function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){ + + require (_value <= _allowances[_from][msg.sender]); + require (_value > 0); + _allowances[_from][msg.sender] -= _value; + _transfer(_from, _to, _value); + return true; + } + //recheck above function + + + + + +} \ No newline at end of file diff --git a/Token_BFA/ERC20.sol b/Token_BFA/ERC20.sol new file mode 100644 index 0000000..e404ab4 --- /dev/null +++ b/Token_BFA/ERC20.sol @@ -0,0 +1,22 @@ +pragma solidity ^0.4.21; + + +interface ERC20 { + + function totalSupply() public view returns (uint256); + function balanceOf(address _owner) public view returns (uint256); + function approve(address _spender, uint256 _value) public returns (bool); + function allowance(address _owner, address _spender) public view returns (uint256); + function transfer(address _to, uint256 _value) public; + function transferFrom(address _from, address _to, uint256 _value) public returns (bool); + + function name() public view returns (string); + function symbol() public view returns (string); + function decimals() public view returns (uint8); + + event Transfer(address indexed _from, address indexed _to, uint256 _value); + event Approval(address indexed _owner, address indexed _spender, uint256 _value); + event Buy(address beneficiary, uint amount); + + +} \ No newline at end of file diff --git a/Token_BFA/ERC223ReceivingContract.sol b/Token_BFA/ERC223ReceivingContract.sol new file mode 100644 index 0000000..6321718 --- /dev/null +++ b/Token_BFA/ERC223ReceivingContract.sol @@ -0,0 +1,6 @@ +pragma solidity ^0.4.21; + +contract ERC223ReceivingContract { + function tokenFallback(address _from, uint _value, bytes _data) public; + +} diff --git a/Token_BFA/SafeMath.sol b/Token_BFA/SafeMath.sol new file mode 100644 index 0000000..17be7ae --- /dev/null +++ b/Token_BFA/SafeMath.sol @@ -0,0 +1,44 @@ +pragma solidity ^0.4.21; + + + +library SafeMath { + + /** + * @dev Multiplies two numbers, throws on overflow. + */ + function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { + if (a == 0) { + return 0; + } + c = a * b; + assert(c / a == b); + return c; + } + + /** + * @dev Integer division of two numbers, truncating the quotient. + */ + function div(uint256 a, uint256 b) internal pure returns (uint256) { + + require (b > 0); + return a / b; + } + + /** + * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). + */ + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + assert(b <= a); + return a - b; + } + + /** + * @dev Adds two numbers, throws on overflow. + */ + function add(uint256 a, uint256 b) internal pure returns (uint256 c) { + c = a + b; + assert(c >= a); + return c; + } +} \ No newline at end of file