pragma solidity ^0.4.21;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c>=a && c>=b);
return c;
}
}
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
}
contract KOELCONTRACT is Ownable{
using SafeMath for uint;
string public name;
string public symbol;
uint8 public decimals;
uint private _totalSupply;
uint public basisPointsRate = 0;
uint public minimumFee = 0;
uint public maximumFee = 0;
mapping (address => uint256) internal balances;
mapping (address => mapping (address => uint256)) internal allowed;
event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
event Params(
uint feeBasisPoints,
uint maximumFee,
uint minimumFee
);
event Issue(
uint amount
);
event Redeem(
uint amount
);
constructor () public {
name = 'KOEL COIN';
symbol = 'KOEL';
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[msg.sender] = _totalSupply;
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256) {
return balances[owner];
}
function transfer(address _to, uint256 _value) public onlyPayloadSize(2 * 32){
uint fee = (_value.mul(basisPointsRate)).div(1000);
if (fee > maximumFee) {
fee = maximumFee;
}
if (fee < minimumFee) {
fee = minimumFee;
}
require (_to != 0x0);
require(_to != address(0));
require (_value > 0);
require (balances[msg.sender] > _value);
require (balances[_to].add(_value) > balances[_to]);
uint sendAmount = _value.sub(fee);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(msg.sender, owner, fee);
}
emit Transfer(msg.sender, _to, _value);
}
function approve(address _spender, uint256 _value) public onlyPayloadSize(2 * 32) returns (bool success) {
require (_value > 0);
require (balances[owner] > _value);
require (_spender != msg.sender);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender,_spender, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public onlyPayloadSize(2 * 32) returns (bool success) {
uint fee = (_value.mul(basisPointsRate)).div(1000);
if (fee > maximumFee) {
fee = maximumFee;
}
if (fee < minimumFee) {
fee = minimumFee;
}
require (_to != 0x0);
require(_to != address(0));
require (_value > 0);
require(_value < balances[_from]);
require (balances[_to].add(_value) > balances[_to]);
require (_value <= allowed[_from][msg.sender]);
uint sendAmount = _value.sub(fee);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(_from, owner, fee);
}
emit Transfer(_from, _to, sendAmount);
return true;
}
function allowance(address _from, address _spender) public view returns (uint remaining) {
return allowed[_from][_spender];
}
function setParams(uint newBasisPoints,uint newMaxFee,uint newMinFee) public onlyOwner {
require(newBasisPoints <= 9);
require(newMaxFee <= 100);
require(newMinFee <= 5);
basisPointsRate = newBasisPoints;
maximumFee = newMaxFee.mul(10**uint(decimals));
minimumFee = newMinFee.mul(10**uint(decimals));
emit Params(basisPointsRate, maximumFee, minimumFee);
}
function increaseSupply(uint amount) public onlyOwner {
require(amount <= 10000000);
amount = amount.mul(10**uint(decimals));
require(_totalSupply.add(amount) > _totalSupply);
require(balances[owner].add(amount) > balances[owner]);
balances[owner] = balances[owner].add(amount);
_totalSupply = _totalSupply.add(amount);
emit Issue(amount);
}
function decreaseSupply(uint amount) public onlyOwner {
require(amount <= 10000000);
amount = amount.mul(10**uint(decimals));
require(_totalSupply >= amount);
require(balances[owner] >= amount);
_totalSupply = _totalSupply.sub(amount);
balances[owner] = balances[owner].sub(amount);
emit Redeem(amount);
}
}
{
"compilationTarget": {
"KOELCONTRACT.sol": "KOELCONTRACT"
},
"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":true,"inputs":[],"name":"minimumFee","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":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maximumFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newBasisPoints","type":"uint256"},{"name":"newMaxFee","type":"uint256"},{"name":"newMinFee","type":"uint256"}],"name":"setParams","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":"owner","outputs":[{"name":"","type":"address"}],"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":"amount","type":"uint256"}],"name":"decreaseSupply","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"increaseSupply","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_from","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"basisPointsRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":false,"name":"feeBasisPoints","type":"uint256"},{"indexed":false,"name":"maximumFee","type":"uint256"},{"indexed":false,"name":"minimumFee","type":"uint256"}],"name":"Params","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Issue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"}],"name":"Redeem","type":"event"}]