pragma solidity ^0.5.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
require(c >= a);
}
function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {
require(b <= a);
c = a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint256 a, uint256 b) internal pure returns (uint256 c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public view returns (uint256);
function balanceOf(address tokenOwner) public view returns (uint256 balance);
function allowance(address tokenOwner, address spender) public view returns (uint256 remaining);
function transfer(address to, uint256 value) public returns (bool success);
function approve(address spender, uint256 value) public returns (bool success);
function transferFrom(address from, address to, uint256 value) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed tokenOwner, address indexed spender, uint256 value);
}
contract CREDIT is ERC20Interface {
using SafeMath for uint256;
string public symbol;
string public name;
uint8 public decimals;
uint256 _totalSupply;
address public owner;
bool public activeStatus = true;
event Active(address msgSender);
event Reset(address msgSender);
event Freeze(address indexed from, uint256 value);
event Unfreeze(address indexed from, uint256 value);
mapping(address => uint256) public balances;
mapping(address => uint256) public freezeOf;
mapping(address => mapping(address => uint256)) public allowed;
constructor() public {
symbol = "CREDIT";
name = "CREDIT";
decimals = 18;
_totalSupply = 100000000 * 10**uint(decimals);
owner = msg.sender;
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
function isOwner(address add) public view returns (bool) {
if (add == owner) {
return true;
} else return false;
}
modifier onlyOwner {
if (!isOwner(msg.sender)) {
revert();
}
_;
}
modifier onlyActive {
if (!activeStatus) {
revert();
}
_;
}
function activeMode() public onlyOwner {
activeStatus = true;
emit Active(msg.sender);
}
function resetMode() public onlyOwner {
activeStatus = false;
emit Reset(msg.sender);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address tokenOwner) public view returns (uint256 balance) {
return balances[tokenOwner];
}
function allowance(address tokenOwner, address spender) public view returns (uint256 remaining) {
return allowed[tokenOwner][spender];
}
function transfer(address to, uint256 value) public onlyActive returns (bool success) {
if (to == address(0)) {
revert();
}
if (value <= 0) {
revert();
}
if (balances[msg.sender] < value) {
revert();
}
balances[msg.sender] = balances[msg.sender].sub(value);
balances[to] = balances[to].add(value);
emit Transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public onlyActive returns (bool success) {
if (value <= 0) {
revert();
}
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public onlyActive returns (bool success) {
if (to == address(0)) {
revert();
}
if (value <= 0) {
revert();
}
if (balances[from] < value) {
revert();
}
if (value > allowed[from][msg.sender]) {
revert();
}
balances[from] = balances[from].sub(value);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
balances[to] = balances[to].add(value);
emit Transfer(from, to, value);
return true;
}
function freeze(uint256 value) public onlyActive returns (bool success) {
if (balances[msg.sender] < value) {
revert();
}
if (value <= 0){
revert();
}
balances[msg.sender] = balances[msg.sender].sub(value);
freezeOf[msg.sender] = freezeOf[msg.sender].add(value);
emit Freeze(msg.sender, value);
return true;
}
function unfreeze(uint256 value) public onlyActive returns (bool success) {
if (freezeOf[msg.sender] < value) {
revert();
}
if (value <= 0) {
revert();
}
freezeOf[msg.sender] = freezeOf[msg.sender].sub(value);
balances[msg.sender] = balances[msg.sender].add(value);
emit Unfreeze(msg.sender, value);
return true;
}
function () external payable {
revert();
}
}
{
"compilationTarget": {
"CREDIT.sol": "CREDIT"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": false,
"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":"success","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":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"add","type":"address"}],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"unfreeze","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"activeStatus","outputs":[{"name":"","type":"bool"}],"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":"activeMode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"freezeOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"freeze","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"resetMode","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"msgSender","type":"address"}],"name":"Active","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"msgSender","type":"address"}],"name":"Reset","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Freeze","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Unfreeze","type":"event"},{"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":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]