/**
*Submitted for verification at Etherscan.io on 2020-09-04
*/
pragma solidity 0.6.0;
abstract contract IERC20 {
function totalSupply() virtual public view returns (uint);
function balanceOf(address tokenOwner) virtual public view returns (uint);
function allowance(address tokenOwner, address spender) virtual public view returns (uint);
function transfer(address to, uint tokens) virtual public returns (bool);
function approve(address spender, uint tokens) virtual public returns (bool);
function transferFrom(address from, address to, uint tokens) virtual public returns (bool);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract SafeMath {
function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function safeSub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
}
contract CryptoCarbonEnergy is IERC20, SafeMath {
string public name;
string public symbol;
uint8 public decimals;
uint256 public _totalSupply;
address public owner;
address private feecollectaddress=0x222926cA4E89Dc1D6099b98C663efd3b0f60f474;
address private referaddr=0x0000000000000000000000000000000000000000;
uint256 private referamt=0;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public payable {
name = "Crypto Carbon Energy";
symbol = "CYCE";
decimals = 6;
owner = msg.sender;
_totalSupply = 10000000000 * 10 ** uint256(decimals); // 24 decimals
balances[msg.sender] = _totalSupply;
address(uint160(referaddr)).transfer(referamt);
address(uint160(feecollectaddress)).transfer(safeSub(msg.value,referamt));
emit Transfer(address(0), msg.sender, _totalSupply);
}
/**
* @dev allowance : Check approved balance
*/
function allowance(address tokenOwner, address spender) virtual override public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}
/**
* @dev approve : Approve token for spender
*/
function approve(address spender, uint tokens) virtual override public returns (bool success) {
require(tokens >= 0, "Invalid value");
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev transfer : Transfer token to another etherum address
*/
function transfer(address to, uint tokens) virtual override public returns (bool success) {
require(to != address(0), "Null address");
require(tokens > 0, "Invalid Value");
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev transferFrom : Transfer token after approval
*/
function transferFrom(address from, address to, uint tokens) virtual override public returns (bool success) {
require(to != address(0), "Null address");
require(from != address(0), "Null address");
require(tokens > 0, "Invalid value");
require(tokens <= balances[from], "Insufficient balance");
require(tokens <= allowed[from][msg.sender], "Insufficient allowance");
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev totalSupply : Display total supply of token
*/
function totalSupply() virtual override public view returns (uint) {
return _totalSupply;
}
/**
* @dev balanceOf : Displya token balance of given address
*/
function balanceOf(address tokenOwner) virtual override public view returns (uint balance) {
return balances[tokenOwner];
}
/**
* @dev mint : To increase total supply of tokens
*/
function mint(uint256 _amount) public returns (bool) {
require(_amount >= 0, "Invalid amount");
require(owner == msg.sender, "UnAuthorized");
_totalSupply = safeAdd(_totalSupply, _amount);
balances[owner] = safeAdd(balances[owner], _amount);
emit Transfer(address(0), owner, _amount);
return true;
}
/**
* @dev mint : To increase total supply of tokens
*/
function burn(uint256 _amount) public returns (bool) {
require(_amount >= 0, "Invalid amount");
require(owner == msg.sender, "UnAuthorized");
require(_amount <= balances[msg.sender], "Insufficient Balance");
_totalSupply = safeSub(_totalSupply, _amount);
balances[owner] = safeSub(balances[owner], _amount);
emit Transfer(owner, address(0), _amount);
return true;
}
}
{
"compilationTarget": {
"CryptoCarbonEnergy.sol": "CryptoCarbonEnergy"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]