/* ==================================================================== */
/* Copyright (c) 2018 The TokenTycoon Project. All rights reserved.
/*
/* https://tokentycoon.io
/*
/* authors rickhunter.shen@gmail.com
/* ssesunding@gmail.com
/* ==================================================================== */
pragma solidity ^0.4.23;
contract AccessAdmin {
bool public isPaused = false;
address public addrAdmin;
event AdminTransferred(address indexed preAdmin, address indexed newAdmin);
constructor() public {
addrAdmin = msg.sender;
}
modifier onlyAdmin() {
require(msg.sender == addrAdmin);
_;
}
modifier whenNotPaused() {
require(!isPaused);
_;
}
modifier whenPaused {
require(isPaused);
_;
}
function setAdmin(address _newAdmin) external onlyAdmin {
require(_newAdmin != address(0));
emit AdminTransferred(addrAdmin, _newAdmin);
addrAdmin = _newAdmin;
}
function doPause() external onlyAdmin whenNotPaused {
isPaused = true;
}
function doUnpause() external onlyAdmin whenPaused {
isPaused = false;
}
}
interface TokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external;
}
contract TalentCard is AccessAdmin {
uint8 public decimals = 0;
uint256 public totalSupply = 1000000000;
string public name = "Token Tycoon Talent Card";
string public symbol = "TTTC";
mapping (address => uint256) balances;
mapping (address => mapping(address => uint256)) allowed;
/// @dev Trust contract
mapping (address => bool) safeContracts;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
constructor() public {
addrAdmin = msg.sender;
balances[this] = totalSupply;
}
function balanceOf(address _owner) external view returns (uint256) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) external view returns (uint256) {
return allowed[_owner][_spender];
}
function transferFrom(address _from, address _to, uint256 _value) external returns (bool) {
require(_value <= allowed[_from][msg.sender]);
allowed[_from][msg.sender] -= _value;
return _transfer(_from, _to, _value);
}
function transfer(address _to, uint256 _value) external returns (bool) {
return _transfer(msg.sender, _to, _value);
}
function _transfer(address _from, address _to, uint256 _value) internal returns (bool) {
require(_to != address(0));
uint256 oldFromVal = balances[_from];
require(_value > 0 && oldFromVal >= _value);
uint256 oldToVal = balances[_to];
uint256 newToVal = oldToVal + _value;
require(newToVal > oldToVal);
uint256 newFromVal = oldFromVal - _value;
balances[_from] = newFromVal;
balances[_to] = newToVal;
assert((oldFromVal + oldToVal) == (newFromVal + newToVal));
emit Transfer(_from, _to, _value);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData)
external
returns (bool success) {
TokenRecipient spender = TokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
function setSafeContract(address _actionAddr, bool _useful) external onlyAdmin {
safeContracts[_actionAddr] = _useful;
}
function getSafeContract(address _actionAddr) external view onlyAdmin returns(bool) {
return safeContracts[_actionAddr];
}
function safeSendCard(uint256 _amount, address _to) external {
require(safeContracts[msg.sender]);
require(balances[address(this)] >= _amount);
require(_to != address(0));
_transfer(address(this), _to, _amount);
}
}
{
"compilationTarget": {
"TalentCard.sol": "TalentCard"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"doUnpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_actionAddr","type":"address"}],"name":"getSafeContract","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"doPause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newAdmin","type":"address"}],"name":"setAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isPaused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"addrAdmin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_actionAddr","type":"address"},{"name":"_useful","type":"bool"}],"name":"setSafeContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"},{"name":"_to","type":"address"}],"name":"safeSendCard","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"preAdmin","type":"address"},{"indexed":true,"name":"newAdmin","type":"address"}],"name":"AdminTransferred","type":"event"}]