pragma solidity ^0.5.11;
library SafeMathMod {// Partial SafeMath Library
function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
require((c = a - b) < a);
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
require((c = a + b) > a);
}
function mul(uint256 a, uint256 b) internal pure returns(uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns(uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public view returns(uint);
function balanceOf(address tokenOwner) public view returns(uint balance);
function allowance(address tokenOwner, address spender) public view returns(uint remaining);
function transfer(address to, uint tokens) public returns(bool success);
function approve(address spender, uint tokens) public returns(bool success);
function transferFrom(address from, address to, uint tokens) public returns(bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public;
}
contract Owned {
address public owner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
emit OwnershipTransferred(owner, newOwner);
}
}
// blacklist
contract UserLock is Owned {
mapping(address => bool) blacklist;
event LockUser(address indexed who);
event UnlockUser(address indexed who);
modifier permissionCheck {
require(!blacklist[msg.sender]);
_;
}
function lockUser(address who) public onlyOwner {
blacklist[who] = true;
emit LockUser(who);
}
function unlockUser(address who) public onlyOwner {
blacklist[who] = false;
emit UnlockUser(who);
}
}
contract Tokenlock is Owned {
uint8 isLocked = 0;
event Freezed();
event UnFreezed();
modifier validLock {
require(isLocked == 0);
_;
}
function freeze() public onlyOwner {
isLocked = 1;
emit Freezed();
}
function unfreeze() public onlyOwner {
isLocked = 0;
emit UnFreezed();
}
}
contract OSDT is ERC20Interface, Tokenlock, UserLock{//is inherently ERC20
using SafeMathMod for uint256;
/**
* @constant name The name of the token
* @constant symbol The symbol used to display the currency
* @constant decimals The number of decimals used to dispay a balance
* @constant totalSupply The total number of tokens times 10^ of the number of decimals
* @constant MAX_UINT256 Magic number for unlimited allowance
* @storage balanceOf Holds the balances of all token holders
* @storage allowed Holds the allowable balance to be transferable by another address.
*/
string constant public name = "OSDT";
string constant public symbol = "OSDT";
uint8 constant public decimals = 6;
uint256 _totalSupply = 10e14;
uint256 constant private MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event TransferFrom(address indexed _spender, address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
constructor() public {
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function totalSupply() public view returns(uint) {
return _totalSupply;
}
function balanceOf(address tokenOwner) public view returns(uint balance) {
return balances[tokenOwner];
}
/**
* @notice send `_value` token to `_to` from `msg.sender`
*
* @param _to The address of the recipient
* @param _value The amount of token to be transferred
* @return Whether the transfer was successful or not
*/
function transfer(address _to, uint256 _value) public validLock permissionCheck returns (bool success) {
/* Ensures that tokens are not sent to address "0x0" */
require(_to != address(0));
/* Prevents sending tokens directly to contracts. */
require(isNotContract(_to));
/* SafeMathMOd.sub will throw if there is not enough balance and if the transfer value is 0. */
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value The amount of token to be transferred
* @return Whether the transfer was successful or not
*/
function transferFrom(address _from, address _to, uint256 _value) public validLock permissionCheck returns (bool success) {
/* Ensures that tokens are not sent to address "0x0" */
require(_to != address(0));
/* Ensures tokens are not sent to this contract */
require(_to != address(this));
uint256 allowance = allowed[_from][msg.sender];
/* Ensures sender has enough available allowance OR sender is balance holder allowing single transsaction send to contracts*/
require(_value <= allowance || _from == msg.sender);
/* Use SafeMathMod to add and subtract from the _to and _from addresses respectively. Prevents under/overflow and 0 transfers */
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
/* Only reduce allowance if not MAX_UINT256 in order to save gas on unlimited allowance */
/* Balance holder does not need allowance to send from self. */
if (allowed[_from][msg.sender] != MAX_UINT256 && _from != msg.sender) {
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
}
emit Transfer(_from, _to, _value);
return true;
}
/**
* @notice `msg.sender` approves `_spender` to spend `_value` tokens
*
* @param _spender The address of the account able to transfer the tokens
* @param _value The amount of tokens to be approved for transfer
* @return Whether the approval was successful or not
*/
function approve(address _spender, uint256 _value) public validLock permissionCheck returns (bool success) {
/* Ensures address "0x0" is not assigned allowance. */
require(_spender != address(0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @param _owner The address of the account owning tokens
* @param _spender The address of the account able to transfer the tokens
* @return Amount of remaining tokens allowed to spent
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
remaining = allowed[_owner][_spender];
}
// trust pay
function approveAndCall(address spender, uint tokens, bytes memory data) public validLock permissionCheck returns(bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function mintToken(address target, uint256 mintedAmount) public onlyOwner {
require(target != address(0));
balances[target] += mintedAmount;
_totalSupply = _totalSupply.add(mintedAmount);
emit Transfer(address(0), owner, mintedAmount);
emit Transfer(owner, target, mintedAmount);
}
function () external payable {
revert();
}
function isNotContract(address _addr) private view returns (bool) {
uint length;
assembly {
/* retrieve the size of the code on target address, this needs assembly */
length := extcodesize(_addr)
}
return (length == 0);
}
}
{
"compilationTarget": {
"OSDT.sol": "OSDT"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"freeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unfreeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint256","name":"mintedAmount","type":"uint256"}],"name":"mintToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"unlockUser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"who","type":"address"}],"name":"lockUser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"TransferFrom","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"}],"name":"LockUser","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"who","type":"address"}],"name":"UnlockUser","type":"event"},{"anonymous":false,"inputs":[],"name":"Freezed","type":"event"},{"anonymous":false,"inputs":[],"name":"UnFreezed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"}]