pragma solidity ^0.4.11; // ---------------------------------------------------------------------------- // Dao.Casino Crowdsale Token Contract // // NOTE: This is the new Dao.Casino token contract as the old Dao.Casino // crowdsale/token contract was attached to a buggy Parity multisig that // was vulnerable to hackers // // Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd for Dao.Casino 2017 // The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths, borrowed from OpenZeppelin // ---------------------------------------------------------------------------- import '../library/SafeMath.sol'; // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { if (msg.sender == newOwner) { owner = newOwner; } } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals // https://github.com/ethereum/EIPs/issues/20 // ---------------------------------------------------------------------------- contract ERC20Token { using SafeMath for uint; // ------------------------------------------------------------------------ // Total Supply // ------------------------------------------------------------------------ uint256 _totalSupply = 0; // ------------------------------------------------------------------------ // Balances for each account // ------------------------------------------------------------------------ mapping(address => uint256) balances; // ------------------------------------------------------------------------ // Owner of account approves the transfer of an amount to another account // ------------------------------------------------------------------------ mapping(address => mapping (address => uint256)) allowed; // ------------------------------------------------------------------------ // Get the total token supply // ------------------------------------------------------------------------ function totalSupply() public view returns (uint256) { return _totalSupply; } // ------------------------------------------------------------------------ // Get the account balance of another account with address _owner // ------------------------------------------------------------------------ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } // ------------------------------------------------------------------------ // Transfer the balance from owner's account to another account // ------------------------------------------------------------------------ function transfer(address _to, uint256 _amount) public returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Allow _spender to withdraw from your account, multiple times, up to the // _value amount. If this function is called again it overwrites the // current allowance with _value. // ------------------------------------------------------------------------ function approve( address _spender, uint256 _amount ) public returns (bool success) { // Borrowed from the MiniMeToken contract // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender,0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _amount; return true; } // ------------------------------------------------------------------------ // Spender of tokens transfer an amount of tokens from the token owner's // balance to the spender's account. The owner of the tokens must already // have approve(...)-d this transfer // ------------------------------------------------------------------------ function transferFrom( address _from, address _to, uint256 _amount ) public returns (bool success) { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); return true; } else { return false; } } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance( address _owner, address _spender ) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract ERC20 is ERC20Token, Owned { // ------------------------------------------------------------------------ // Token information // ------------------------------------------------------------------------ string public constant name = "TEST BET"; string public constant symbol = "BET"; uint8 public constant decimals = 18; constructor() public { } // ------------------------------------------------------------------------ // Only for testing in testnet // ------------------------------------------------------------------------ function faucet() public { balances[msg.sender] = balances[msg.sender].add(10000 ether); _totalSupply = _totalSupply.add(10000 ether); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint amount) public onlyOwner returns (bool success) { return ERC20Token(tokenAddress).transfer(owner, amount); } }