文件 1 的 14:BurnableToken.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ERC20Basic.sol";
contract BurnableToken is ERC20Basic {
using SafeMath for uint256;
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public returns (bool){
address _who = msg.sender;
require(_value <= balances[_who]);
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
return true;
}
}
文件 2 的 14:CanReclaimToken.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ERC20If.sol";
import "OwnableIf.sol";
abstract contract CanReclaimToken is OwnableIf {
function reclaimToken(ERC20If _token) external onlyOwner {
uint256 balance = _token.balanceOf((address)(this));
require(_token.transfer(_owner(), balance));
}
}
文件 3 的 14:Claimable.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "Ownable.sol";
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "no permission");
_;
}
function transferOwnership(address newOwner) override public onlyOwner {
pendingOwner = newOwner;
}
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
文件 4 的 14:ERC20Basic.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ERC20If.sol";
import "SafeMathLib.sol";
contract ERC20Basic is ERC20If {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
mapping(address => mapping(address => uint256)) internal allowed;
uint256 internal totalSupply_;
function _notPaused() virtual internal view returns (bool){return false;}
function _notBlocked(address) virtual internal view returns (bool){return false;}
modifier notPaused() {
require(_notPaused(), "contract has been paused");
_;
}
modifier notBlocked() {
require(_notBlocked(msg.sender), "sender has been blocked");
_;
}
function totalSupply() override public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) override public notPaused notBlocked returns (bool) {
require(_notBlocked(_to), "to-address has been blocked");
require(_value <= balances[msg.sender], "insufficient balance");
require(_to != address(0), "invalid to-address");
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _owner) override public view returns (uint256) {
return balances[_owner];
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
override public notPaused notBlocked
returns (bool)
{
require(_notBlocked(_from), "from-address has been blocked");
require(_notBlocked(_to), "to-address has been blocked");
require(_value <= balances[_from], "insufficient balance");
require(_to != address(0), "invalid to-address");
if (_from == msg.sender){
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
return true;
}
require(_value <= allowed[_from][msg.sender], "value > allowed");
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value)
override public notPaused notBlocked
returns (bool) {
require(_notBlocked(_spender), "spender-address has been blocked");
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function increaseApproval(
address _spender,
uint256 _addedValue
)
public notPaused notBlocked
returns (bool)
{
require(_notBlocked(_spender), "spender-address has been blocked");
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
notPaused notBlocked
returns (bool success)
{
require(_notBlocked(_spender), "spender-address has been blocked");
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function allowance(
address _owner,
address _spender
)
override
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
}
文件 5 的 14:ERC20If.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
abstract contract ERC20If {
function totalSupply() virtual public view returns (uint256);
function balanceOf(address _who) virtual public view returns (uint256);
function transfer(address _to, uint256 _value) virtual public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
function allowance(address _owner, address _spender) virtual public view returns (uint256);
function transferFrom(address _from, address _to, uint256 _value) virtual public returns (bool);
function approve(address _spender, uint256 _value) virtual public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
文件 6 的 14:MemberMgrIf.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
abstract contract MemberMgrIf {
function requireMerchant(address _who) virtual public view;
function requireCustodian(address _who) virtual public view;
}
文件 7 的 14:MintableERC20.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ERC20Basic.sol";
import "OwnableIf.sol";
abstract contract MintableERC20 is ERC20Basic, OwnableIf {
using SafeMath for uint256;
event Mint(address indexed to, uint256 amount);
event MintFinished(bool indexed finished);
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished, "can't mint");
_;
}
modifier hasMintPermission() {
require(msg.sender == _owner(), "no permission...");
_;
}
function mint(
address _to,
uint256 _amount
)
public
hasMintPermission
canMint
notPaused
returns (bool)
{
require(_notBlocked(_to), "to-address has been blocked");
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function finishMinting(bool finished)
public
onlyOwner
returns (bool) {
mintingFinished = finished;
emit MintFinished(mintingFinished);
return true;
}
}
文件 8 的 14:NamedERC20.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
contract NamedERC20 {
string public name;
string public symbol;
uint8 public decimals;
constructor(string memory _name, string memory _symbol, uint8 _decimals) {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
文件 9 的 14:Ownable.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "OwnableIf.sol";
contract Ownable is OwnableIf {
address public owner;
function _owner() view override public returns (address){
return owner;
}
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
owner = msg.sender;
}
function transferOwnership(address _newOwner) virtual public onlyOwner {
_transferOwnership(_newOwner);
}
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0), "invalid _newOwner");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
文件 10 的 14:OwnableIf.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
abstract contract OwnableIf {
modifier onlyOwner() {
require(msg.sender == _owner(), "not owner......");
_;
}
function _owner() view virtual public returns (address);
}
文件 11 的 14:SafeMathLib.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
文件 12 的 14:ccBCH.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ccToken.sol";
contract ccBCH is ccToken {
constructor() ccToken("Cross-Chain BCH", "ccBCH", 8, (ERC20ControllerViewIf)(0)){}
}
文件 13 的 14:ccToken.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "ccTokenControllerIf.sol";
import "NamedERC20.sol";
import "MintableERC20.sol";
import "BurnableToken.sol";
import "Claimable.sol";
import "CanReclaimToken.sol";
contract ccToken is NamedERC20, Claimable, MintableERC20, BurnableToken, CanReclaimToken {
using SafeMath for uint256;
ERC20ControllerViewIf public erc20Controller;
constructor(string memory _name,
string memory _symbol,
uint8 _decimals,
ERC20ControllerViewIf _erc20Controller
) NamedERC20(_name, _symbol, _decimals){
erc20Controller = _erc20Controller;
}
function hasController() view public returns (bool){
return (address)(erc20Controller) != (address)(0);
}
function _notPaused() override internal view returns (bool){
if (hasController()) {
return !erc20Controller.paused();
}
return true;
}
function _notBlocked(address _who) override internal view returns (bool){
if (hasController()) {
return !erc20Controller.blocked(_who);
}
return true;
}
function setController(ERC20ControllerViewIf newController) public onlyOwner {
erc20Controller = newController;
}
event BurnBlocked(address indexed burner, uint256 value);
function burnBlocked(address addrBlocked, uint256 amount) public onlyOwner returns (bool){
address _who = addrBlocked;
require(!_notBlocked(_who), "addr not blocked");
uint256 _value = amount;
if (_value > balances[_who]) {
_value = balances[_who];
}
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit BurnBlocked(_who, _value);
emit Transfer(_who, address(0), _value);
return true;
}
}
文件 14 的 14:ccTokenControllerIf.sol
pragma solidity ^0.7.0;
pragma experimental SMTChecker;
import "MemberMgrIf.sol";
import "ERC20If.sol";
abstract contract ERC20ControllerViewIf {
function blocked(address _who) virtual public view returns (bool);
function paused() virtual public view returns (bool);
}
abstract contract ccTokenControllerIf is MemberMgrIf, ERC20ControllerViewIf {
function mint(address to, uint amount) virtual external returns (bool);
function burn(uint value) virtual external returns (bool);
function getToken() virtual external returns (ERC20If);
}
{
"compilationTarget": {
"ccBCH.sol": "ccBCH"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":"burner","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"burner","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"BurnBlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bool","name":"finished","type":"bool"}],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","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":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addrBlocked","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnBlocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"erc20Controller","outputs":[{"internalType":"contract ERC20ControllerViewIf","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"finished","type":"bool"}],"name":"finishMinting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"hasController","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintingFinished","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20If","name":"_token","type":"address"}],"name":"reclaimToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ERC20ControllerViewIf","name":"newController","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","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":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"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":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]