文件 1 的 16:CALL.sol
pragma solidity 0.5.8;
import "./ERC777ERC20Compat.sol";
import "./SafeGuard.sol";
import { CStore } from "./CStore.sol";
contract CALL is ERC777ERC20Compat, SafeGuard {
constructor(
string memory _name,
string memory _symbol,
uint256 _granularity,
uint256 _totalSupply,
address _initialOwner,
address[] memory _defaultOperators
)
public ERC777ERC20Compat(_name, _symbol, _granularity, _totalSupply, _initialOwner, _defaultOperators)
{
requireMultiple(_totalSupply);
require(balancesDB.setModule(address(this), true), "Cannot enable access to the database.");
balancesDB.transferOwnership(_initialOwner);
callRecipient(msg.sender, address(0), _initialOwner, _totalSupply, "", "", true);
emit Minted(msg.sender, _initialOwner, _totalSupply, "", "");
if (mErc20compatible) { emit Transfer(address(0), _initialOwner, _totalSupply); }
}
function changeBalancesDB(address _newDB) public onlyOwner {
balancesDB = CStore(_newDB);
}
function disableERC20() public onlyOwner {
mErc20compatible = false;
setInterfaceImplementation("ERC20Token", address(0));
}
function enableERC20() public onlyOwner {
mErc20compatible = true;
setInterfaceImplementation("ERC20Token", address(this));
}
function multiPartyTransfer(address[] calldata _toAddresses, uint256[] calldata _amounts) external erc20 {
require(_toAddresses.length <= 255, "Unsupported number of addresses.");
require(_toAddresses.length == _amounts.length, "Provided addresses does not equal to provided sums.");
for (uint8 i = 0; i < _toAddresses.length; i++) {
transfer(_toAddresses[i], _amounts[i]);
}
}
function multiPartyTransferFrom(address _from, address[] calldata _toAddresses, uint256[] calldata _amounts) external erc20 {
require(_toAddresses.length <= 255, "Unsupported number of addresses.");
require(_toAddresses.length == _amounts.length, "Provided addresses does not equal to provided sums.");
for (uint8 i = 0; i < _toAddresses.length; i++) {
transferFrom(_from, _toAddresses[i], _amounts[i]);
}
}
function multiPartySend(address[] memory _toAddresses, uint256[] memory _amounts, bytes memory _userData) public {
require(_toAddresses.length <= 255, "Unsupported number of addresses.");
require(_toAddresses.length == _amounts.length, "Provided addresses does not equal to provided sums.");
for (uint8 i = 0; i < _toAddresses.length; i++) {
doSend(msg.sender, msg.sender, _toAddresses[i], _amounts[i], _userData, "", true);
}
}
function multiOperatorSend(address _from, address[] calldata _to, uint256[] calldata _amounts, bytes calldata _userData, bytes calldata _operatorData)
external {
require(_to.length <= 255, "Unsupported number of addresses.");
require(_to.length == _amounts.length, "Provided addresses does not equal to provided sums.");
for (uint8 i = 0; i < _to.length; i++) {
require(isOperatorFor(msg.sender, _from), "Not an operator");
doSend(msg.sender, _from, _to[i], _amounts[i], _userData, _operatorData, true);
}
}
}
文件 2 的 16:CStore.sol
pragma solidity 0.5.8;
import "./ERC644Balances.sol";
import { ERC1820Client } from "./ERC1820Client.sol";
contract CStore is ERC644Balances, ERC1820Client {
address[] internal mDefaultOperators;
mapping(address => bool) internal mIsDefaultOperator;
mapping(address => mapping(address => bool)) internal mRevokedDefaultOperator;
mapping(address => mapping(address => bool)) internal mAuthorizedOperators;
constructor(uint256 _totalSupply, address _initialOwner, address[] memory _defaultOperators) public
{
balances[_initialOwner] = _totalSupply;
totalSupply = _totalSupply;
mDefaultOperators = _defaultOperators;
for (uint256 i = 0; i < mDefaultOperators.length; i++) { mIsDefaultOperator[mDefaultOperators[i]] = true; }
setInterfaceImplementation("ERC644Balances", address(this));
}
function incTotalSupply(uint _val) external onlyModule returns (bool) {
return false;
}
function decTotalSupply(uint _val) external onlyModule returns (bool) {
return false;
}
function move(address _from, address _to, uint256 _amount) external
onlyModule
returns (bool) {
balances[_from] = balances[_from].sub(_amount);
emit BalanceAdj(msg.sender, _from, _amount, "-");
balances[_to] = balances[_to].add(_amount);
emit BalanceAdj(msg.sender, _to, _amount, "+");
return true;
}
function setAuthorizedOperator(address _operator, address _tokenHolder, bool _status) external
onlyModule
returns (bool) {
mAuthorizedOperators[_operator][_tokenHolder] = _status;
return true;
}
function setRevokedDefaultOperator(address _operator, address _tokenHolder, bool _status) external
onlyModule
returns (bool) {
mRevokedDefaultOperator[_operator][_tokenHolder] = _status;
return true;
}
function getAuthorizedOperator(address _operator, address _tokenHolder) external
view
returns (bool) {
return mAuthorizedOperators[_operator][_tokenHolder];
}
function getDefaultOperator(address _operator) external view returns (bool) {
return mIsDefaultOperator[_operator];
}
function getDefaultOperators() external view returns (address[] memory) {
return mDefaultOperators;
}
function getRevokedDefaultOperator(address _operator, address _tokenHolder) external view returns (bool) {
return mRevokedDefaultOperator[_operator][_tokenHolder];
}
function incBalance(address _acct, uint _val) public onlyModule returns (bool) {
return false;
}
function decBalance(address _acct, uint _val) public onlyModule returns (bool) {
return false;
}
}
文件 3 的 16:Context.sol
pragma solidity ^0.5.0;
contract Context {
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this;
return msg.data;
}
}
文件 4 的 16:ERC1820Client.sol
pragma solidity ^0.5.3;
contract ERC1820Registry {
function setInterfaceImplementer(address _addr, bytes32 _interfaceHash, address _implementer) external;
function getInterfaceImplementer(address _addr, bytes32 _interfaceHash) external view returns (address);
function setManager(address _addr, address _newManager) external;
function getManager(address _addr) public view returns (address);
}
contract ERC1820Client {
ERC1820Registry constant ERC1820REGISTRY = ERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
function setInterfaceImplementation(string memory _interfaceLabel, address _implementation) internal {
bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel));
ERC1820REGISTRY.setInterfaceImplementer(address(this), interfaceHash, _implementation);
}
function interfaceAddr(address addr, string memory _interfaceLabel) internal view returns(address) {
bytes32 interfaceHash = keccak256(abi.encodePacked(_interfaceLabel));
return ERC1820REGISTRY.getInterfaceImplementer(addr, interfaceHash);
}
function delegateManagement(address _newManager) internal {
ERC1820REGISTRY.setManager(address(this), _newManager);
}
}
文件 5 的 16:ERC644Balances.sol
pragma solidity 0.5.8;
import "./SafeMath.sol";
import "./SafeGuard.sol";
import "./IERC644.sol";
contract ERC644Balances is IERC644, SafeGuard {
using SafeMath for uint256;
uint256 public totalSupply;
event BalanceAdj(address indexed module, address indexed account, uint amount, string polarity);
event ModuleSet(address indexed module, bool indexed set);
mapping(address => bool) public modules;
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowed;
modifier onlyModule() {
require(modules[msg.sender], "ERC644Balances: caller is not a module");
_;
}
function setApprove(address _sender, address _spender, uint256 _value) external onlyModule returns (bool) {
allowed[_sender][_spender] = _value;
return true;
}
function decApprove(address _from, address _spender, uint _value) external onlyModule returns (bool) {
allowed[_from][_spender] = allowed[_from][_spender].sub(_value);
return true;
}
function incTotalSupply(uint _val) external onlyModule returns (bool) {
totalSupply = totalSupply.add(_val);
return true;
}
function decTotalSupply(uint _val) external onlyModule returns (bool) {
totalSupply = totalSupply.sub(_val);
return true;
}
function setModule(address _acct, bool _set) external onlyOwner returns (bool) {
modules[_acct] = _set;
emit ModuleSet(_acct, _set);
return true;
}
function getBalance(address _acct) external view returns (uint256) {
return balances[_acct];
}
function getAllowance(address _owner, address _spender) external view returns (uint256) {
return allowed[_owner][_spender];
}
function getModule(address _acct) external view returns (bool) {
return modules[_acct];
}
function getTotalSupply() external view returns (uint256) {
return totalSupply;
}
function incBalance(address _acct, uint _val) public onlyModule returns (bool) {
balances[_acct] = balances[_acct].add(_val);
emit BalanceAdj(msg.sender, _acct, _val, "+");
return true;
}
function decBalance(address _acct, uint _val) public onlyModule returns (bool) {
balances[_acct] = balances[_acct].sub(_val);
emit BalanceAdj(msg.sender, _acct, _val, "-");
return true;
}
function transferRoot(address _new) external returns (bool) {
return false;
}
}
文件 6 的 16:ERC777.sol
pragma solidity 0.5.8;
import { ERC1820Client } from "./ERC1820Client.sol";
import { SafeMath } from "./SafeMath.sol";
import { IERC777 } from "./IERC777.sol";
import { IERC777TokensSender } from "./IERC777TokensSender.sol";
import { IERC777TokensRecipient } from "./IERC777TokensRecipient.sol";
contract ERC777 is IERC777, ERC1820Client {
using SafeMath for uint256;
string internal mName;
string internal mSymbol;
uint256 internal mGranularity;
uint256 internal mTotalSupply;
mapping(address => uint) internal mBalances;
address[] internal mDefaultOperators;
mapping(address => bool) internal mIsDefaultOperator;
mapping(address => mapping(address => bool)) internal mRevokedDefaultOperator;
mapping(address => mapping(address => bool)) internal mAuthorizedOperators;
constructor(
string memory _name,
string memory _symbol,
uint256 _granularity,
address[] memory _defaultOperators
) internal {
mName = _name;
mSymbol = _symbol;
mTotalSupply = 0;
require(_granularity >= 1, "Granularity must be > 1");
mGranularity = _granularity;
mDefaultOperators = _defaultOperators;
for (uint256 i = 0; i < mDefaultOperators.length; i++) { mIsDefaultOperator[mDefaultOperators[i]] = true; }
setInterfaceImplementation("ERC777Token", address(this));
}
function name() public view returns (string memory) { return mName; }
function symbol() public view returns (string memory) { return mSymbol; }
function granularity() public view returns (uint256) { return mGranularity; }
function totalSupply() public view returns (uint256) { return mTotalSupply; }
function balanceOf(address _tokenHolder) public view returns (uint256) { return mBalances[_tokenHolder]; }
function defaultOperators() public view returns (address[] memory) { return mDefaultOperators; }
function send(address _to, uint256 _amount, bytes calldata _data) external {
doSend(msg.sender, msg.sender, _to, _amount, _data, "", true);
}
function authorizeOperator(address _operator) external {
require(_operator != msg.sender, "Cannot authorize yourself as an operator");
if (mIsDefaultOperator[_operator]) {
mRevokedDefaultOperator[_operator][msg.sender] = false;
} else {
mAuthorizedOperators[_operator][msg.sender] = true;
}
emit AuthorizedOperator(_operator, msg.sender);
}
function revokeOperator(address _operator) external {
require(_operator != msg.sender, "Cannot revoke yourself as an operator");
if (mIsDefaultOperator[_operator]) {
mRevokedDefaultOperator[_operator][msg.sender] = true;
} else {
mAuthorizedOperators[_operator][msg.sender] = false;
}
emit RevokedOperator(_operator, msg.sender);
}
function isOperatorFor(address _operator, address _tokenHolder) public view returns (bool) {
return (_operator == _tokenHolder
|| mAuthorizedOperators[_operator][_tokenHolder]
|| (mIsDefaultOperator[_operator] && !mRevokedDefaultOperator[_operator][_tokenHolder]));
}
function operatorSend(
address _from,
address _to,
uint256 _amount,
bytes calldata _data,
bytes calldata _operatorData
)
external
{
require(isOperatorFor(msg.sender, _from), "Not an operator.");
doSend(msg.sender, _from, _to, _amount, _data, _operatorData, true);
}
function burn(uint256 _amount, bytes calldata _data) external {
doBurn(msg.sender, msg.sender, _amount, _data, "");
}
function operatorBurn(
address _tokenHolder,
uint256 _amount,
bytes calldata _data,
bytes calldata _operatorData
)
external
{
require(isOperatorFor(msg.sender, _tokenHolder), "Not an operator");
doBurn(msg.sender, _tokenHolder, _amount, _data, _operatorData);
}
function requireMultiple(uint256 _amount) internal view {
require(_amount % mGranularity == 0, "Amount is not a multiple of granularity");
}
function isRegularAddress(address _addr) internal view returns(bool) {
if (_addr == address(0)) { return false; }
uint size;
assembly { size := extcodesize(_addr) }
return size == 0;
}
function doSend(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData,
bool _preventLocking
)
internal
{
requireMultiple(_amount);
callSender(_operator, _from, _to, _amount, _data, _operatorData);
require(_to != address(0), "Cannot send to 0x0");
require(mBalances[_from] >= _amount, "Not enough funds");
mBalances[_from] = mBalances[_from].sub(_amount);
mBalances[_to] = mBalances[_to].add(_amount);
callRecipient(_operator, _from, _to, _amount, _data, _operatorData, _preventLocking);
emit Sent(_operator, _from, _to, _amount, _data, _operatorData);
}
function doBurn(
address _operator,
address _tokenHolder,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData
)
internal
{
callSender(_operator, _tokenHolder, address(0), _amount, _data, _operatorData);
requireMultiple(_amount);
require(balanceOf(_tokenHolder) >= _amount, "Not enough funds");
mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount);
mTotalSupply = mTotalSupply.sub(_amount);
emit Burned(_operator, _tokenHolder, _amount, _data, _operatorData);
}
function callRecipient(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData,
bool _preventLocking
)
internal
{
address recipientImplementation = interfaceAddr(_to, "ERC777TokensRecipient");
if (recipientImplementation != address(0)) {
IERC777TokensRecipient(recipientImplementation).tokensReceived(
_operator, _from, _to, _amount, _data, _operatorData);
} else if (_preventLocking) {
require(isRegularAddress(_to), "Cannot send to contract without ERC777TokensRecipient");
}
}
function callSender(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData
)
internal
{
address senderImplementation = interfaceAddr(_from, "ERC777TokensSender");
if (senderImplementation == address(0)) { return; }
IERC777TokensSender(senderImplementation).tokensToSend(
_operator, _from, _to, _amount, _data, _operatorData);
}
}
文件 7 的 16:ERC777ERC20Compat.sol
pragma solidity 0.5.8;
import { IERC20 } from "./IERC20.sol";
import { ERC777RemoteBridge } from "./ERC777RemoteBridge.sol";
contract ERC777ERC20Compat is IERC20, ERC777RemoteBridge {
bool internal mErc20compatible;
mapping(address => mapping(address => uint256)) internal mAllowed;
constructor(
string memory _name,
string memory _symbol,
uint256 _granularity,
uint256 _totalSupply,
address _initialOwner,
address[] memory _defaultOperators
)
internal ERC777RemoteBridge(_name, _symbol, _granularity, _totalSupply, _initialOwner, _defaultOperators)
{
mErc20compatible = true;
setInterfaceImplementation("ERC20Token", address(this));
}
modifier erc20 () {
require(mErc20compatible, "ERC20 is disabled");
_;
}
function decimals() public erc20 view returns (uint8) { return uint8(18); }
function transfer(address _to, uint256 _amount) public erc20 returns (bool success) {
doSend(msg.sender, msg.sender, _to, _amount, "", "", false);
return true;
}
function transferFrom(address _from, address _to, uint256 _amount) public erc20 returns (bool success) {
uint256 allowance = balancesDB.getAllowance(_from, msg.sender);
require(_amount <= allowance, "Not enough allowance.");
require(balancesDB.decApprove(_from, msg.sender, _amount));
doSend(msg.sender, _from, _to, _amount, "", "", false);
return true;
}
function approve(address _spender, uint256 _amount) public erc20 returns (bool success) {
require(balancesDB.setApprove(msg.sender, _spender, _amount));
emit Approval(msg.sender, _spender, _amount);
return true;
}
function allowance(address _owner, address _spender) public erc20 view returns (uint256 remaining) {
return balancesDB.getAllowance(_owner, _spender);
}
function doSend(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData,
bool _preventLocking
)
internal
{
super.doSend(_operator, _from, _to, _amount, _data, _operatorData, _preventLocking);
if (mErc20compatible) { emit Transfer(_from, _to, _amount); }
}
function doBurn(
address _operator,
address _tokenHolder,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData
)
internal
{
super.doBurn(_operator, _tokenHolder, _amount, _data, _operatorData);
if (mErc20compatible) { emit Transfer(_tokenHolder, address(0), _amount); }
}
}
文件 8 的 16:ERC777RemoteBridge.sol
pragma solidity 0.5.8;
import { ERC777 } from "./ERC777.sol";
import { CStore } from "./CStore.sol";
contract ERC777RemoteBridge is ERC777 {
CStore public balancesDB;
constructor(
string memory _name,
string memory _symbol,
uint256 _granularity,
uint256 _totalSupply,
address _initialOwner,
address[] memory _defaultOperators
)
public ERC777(_name, _symbol, _granularity, new address[](0))
{
balancesDB = new CStore(_totalSupply, _initialOwner, _defaultOperators);
}
function totalSupply() public view returns (uint256) {
return balancesDB.getTotalSupply();
}
function balanceOf(address _tokenHolder) public view returns (uint256) {
return balancesDB.getBalance(_tokenHolder);
}
function defaultOperators() public view returns (address[] memory) {
return balancesDB.getDefaultOperators();
}
function authorizeOperator(address _operator) external {
require(_operator != msg.sender, "Cannot authorize yourself as an operator");
if (balancesDB.getDefaultOperator(_operator)) {
require(balancesDB.setRevokedDefaultOperator(_operator, msg.sender, false));
} else {
require(balancesDB.setAuthorizedOperator(_operator, msg.sender, true));
}
emit AuthorizedOperator(_operator, msg.sender);
}
function revokeOperator(address _operator) external {
require(_operator != msg.sender, "Cannot revoke yourself as an operator");
if (balancesDB.getDefaultOperator(_operator)) {
require(balancesDB.setRevokedDefaultOperator(_operator, msg.sender, true));
} else {
require(balancesDB.setAuthorizedOperator(_operator, msg.sender, false));
}
emit RevokedOperator(_operator, msg.sender);
}
function isOperatorFor(address _operator, address _tokenHolder) public view returns (bool) {
return _operator == _tokenHolder || balancesDB.getAuthorizedOperator(_operator, _tokenHolder);
return (_operator == _tokenHolder
|| balancesDB.getAuthorizedOperator(_operator, _tokenHolder)
|| (balancesDB.getDefaultOperator(_operator) && !balancesDB.getRevokedDefaultOperator(_operator, _tokenHolder)));
}
function doSend(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData,
bool _preventLocking
)
internal
{
requireMultiple(_amount);
callSender(_operator, _from, _to, _amount, _data, _operatorData);
require(_to != address(0), "Cannot send to 0x0");
require(balancesDB.move(_from, _to, _amount));
callRecipient(_operator, _from, _to, _amount, _data, _operatorData, _preventLocking);
emit Sent(_operator, _from, _to, _amount, _data, _operatorData);
}
function doBurn(
address _operator,
address _tokenHolder,
uint256 _amount,
bytes memory _data,
bytes memory _operatorData
)
internal
{
revert("Burning functionality is disabled.");
}
}
文件 9 的 16:IERC20.sol
pragma solidity ^0.5.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 10 的 16:IERC644.sol
pragma solidity 0.5.8;
interface IERC644 {
function getBalance(address _acct) external view returns(uint);
function incBalance(address _acct, uint _val) external returns(bool);
function decBalance(address _acct, uint _val) external returns(bool);
function getAllowance(address _owner, address _spender) external view returns(uint);
function setApprove(address _sender, address _spender, uint256 _value) external returns(bool);
function decApprove(address _from, address _spender, uint _value) external returns(bool);
function getModule(address _acct) external view returns (bool);
function setModule(address _acct, bool _set) external returns(bool);
function getTotalSupply() external view returns(uint);
function incTotalSupply(uint _val) external returns(bool);
function decTotalSupply(uint _val) external returns(bool);
function transferRoot(address _new) external returns(bool);
event BalanceAdj(address indexed Module, address indexed Account, uint Amount, string Polarity);
event ModuleSet(address indexed Module, bool indexed Set);
}
文件 11 的 16:IERC777.sol
pragma solidity 0.5.8;
interface IERC777 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function granularity() external view returns (uint256);
function defaultOperators() external view returns (address[] memory);
function isOperatorFor(address operator, address tokenHolder) external view returns (bool);
function authorizeOperator(address operator) external;
function revokeOperator(address operator) external;
function send(address to, uint256 amount, bytes calldata data) external;
function operatorSend(
address from,
address to,
uint256 amount,
bytes calldata data,
bytes calldata operatorData
) external;
function burn(uint256 amount, bytes calldata data) external;
function operatorBurn(address from, uint256 amount, bytes calldata data, bytes calldata operatorData) external;
event Sent(
address indexed operator,
address indexed from,
address indexed to,
uint256 amount,
bytes data,
bytes operatorData
);
event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData);
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
event RevokedOperator(address indexed operator, address indexed tokenHolder);
}
文件 12 的 16:IERC777TokensRecipient.sol
pragma solidity 0.5.8;
interface IERC777TokensRecipient {
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata data,
bytes calldata operatorData
) external;
}
文件 13 的 16:IERC777TokensSender.sol
pragma solidity 0.5.8;
interface IERC777TokensSender {
function tokensToSend(
address operator,
address from,
address to,
uint amount,
bytes calldata data,
bytes calldata operatorData
) external;
}
文件 14 的 16:Ownable.sol
pragma solidity ^0.5.0;
import "./Context.sol";
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 15 的 16:SafeGuard.sol
pragma solidity 0.5.8;
import "./Ownable.sol";
contract SafeGuard is Ownable {
event Transaction(address indexed destination, uint value, bytes data);
function executeTransaction(address destination, uint value, bytes memory data)
public
onlyOwner
{
require(externalCall(destination, value, data.length, data));
emit Transaction(destination, value, data);
}
function externalCall(address destination, uint value, uint dataLength, bytes memory data)
private
returns (bool) {
bool result;
assembly {
let x := mload(0x40)
let d := add(data, 32)
result := call(
sub(gas, 34710),
destination,
value,
d,
dataLength,
x,
0
)
}
return result;
}
}
文件 16 的 16:SafeMath.sol
pragma solidity ^0.5.0;
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;
}
}
{
"compilationTarget": {
"CALL.sol": "CALL"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"defaultOperators","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"enableERC20","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"balancesDB","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","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":"_amount","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":false,"inputs":[{"name":"_newDB","type":"address"}],"name":"changeBalancesDB","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"destination","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"executeTransaction","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"granularity","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"},{"name":"_operatorData","type":"bytes"}],"name":"operatorSend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address[]"},{"name":"_amounts","type":"uint256[]"},{"name":"_userData","type":"bytes"},{"name":"_operatorData","type":"bytes"}],"name":"multiOperatorSend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_toAddresses","type":"address[]"},{"name":"_amounts","type":"uint256[]"}],"name":"multiPartyTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_tokenHolder","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"}],"name":"authorizeOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"send","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_toAddresses","type":"address[]"},{"name":"_amounts","type":"uint256[]"}],"name":"multiPartyTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_operator","type":"address"},{"name":"_tokenHolder","type":"address"}],"name":"isOperatorFor","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_toAddresses","type":"address[]"},{"name":"_amounts","type":"uint256[]"},{"name":"_userData","type":"bytes"}],"name":"multiPartySend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disableERC20","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_operator","type":"address"}],"name":"revokeOperator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokenHolder","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"},{"name":"_operatorData","type":"bytes"}],"name":"operatorBurn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_granularity","type":"uint256"},{"name":"_totalSupply","type":"uint256"},{"name":"_initialOwner","type":"address"},{"name":"_defaultOperators","type":"address[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"destination","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"}],"name":"Transaction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"},{"indexed":false,"name":"operatorData","type":"bytes"}],"name":"Sent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"},{"indexed":false,"name":"operatorData","type":"bytes"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"data","type":"bytes"},{"indexed":false,"name":"operatorData","type":"bytes"}],"name":"Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"tokenHolder","type":"address"}],"name":"AuthorizedOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"operator","type":"address"},{"indexed":true,"name":"tokenHolder","type":"address"}],"name":"RevokedOperator","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":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}]