编译器
0.4.24+commit.e67f0147
文件 1 的 14:BasicToken.sol
pragma solidity ^0.4.23;
import "./ERC20Basic.sol";
import "./SafeMath.sol";
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "Trying to transfer tokens to an invalid address");
require(_value <= balances[msg.sender], "Sender's balance is too low for this transfer");
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) public view returns (uint256) {
return balances[_owner];
}
}
文件 2 的 14:BurnableToken.sol
pragma solidity ^0.4.23;
import "./BasicToken.sol";
contract BurnableToken is BasicToken {
event Burn(address indexed burner, uint256 value);
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who], "Not enough tokens to burn");
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
}
文件 3 的 14:Consts.sol
pragma solidity ^0.4.23;
contract Consts {
string constant TOKEN_NAME = "AI Network";
string constant TOKEN_SYMBOL = "AIN";
uint8 constant TOKEN_DECIMALS = 18;
uint256 constant TOKEN_AMOUNT = 700000000;
uint256 SALE_HARD_CAP = 30000;
uint256 SALE_RATE = 10000;
uint256 SALE_MIN_ETH = 1 ether;
uint256 SALE_MAX_ETH = 1000 ether;
}
文件 4 的 14:ERC20.sol
pragma solidity ^0.4.23;
import "./ERC20Basic.sol";
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public view returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 5 的 14:ERC20Basic.sol
pragma solidity ^0.4.23;
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
文件 6 的 14:FreezableToken.sol
pragma solidity ^0.4.23;
import "./Ownable.sol";
import "./StandardToken.sol";
contract FreezableToken is StandardToken, Ownable {
mapping (address => bool) public freezeAddresses;
event FreezableAddressAdded(address indexed addr);
event FreezableAddressRemoved(address indexed addr);
function addFreezableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (addFreezableAddress(addrs[i])) {
success = true;
}
}
}
function addFreezableAddress(address addr) public onlyOwner returns(bool success) {
if (!freezeAddresses[addr]) {
freezeAddresses[addr] = true;
emit FreezableAddressAdded(addr);
success = true;
}
}
function removeFreezableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (removeFreezableAddress(addrs[i])) {
success = true;
}
}
}
function removeFreezableAddress(address addr) public onlyOwner returns(bool success) {
if (freezeAddresses[addr]) {
freezeAddresses[addr] = false;
emit FreezableAddressRemoved(addr);
success = true;
}
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(!freezeAddresses[_from], "Address to transfer from has been frozen");
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(!freezeAddresses[msg.sender], "Sender's address has been frozen");
return super.transfer(_to, _value);
}
}
文件 7 的 14:MainToken.sol
pragma solidity ^0.4.23;
import "./Consts.sol";
import "./FreezableToken.sol";
import "./TransferableToken.sol";
import "./PausableToken.sol";
import "./MintableToken.sol";
import "./BurnableToken.sol";
contract MainToken is Consts
, FreezableToken
, TransferableToken
, PausableToken
, MintableToken
, BurnableToken
{
string public constant name = TOKEN_NAME;
string public constant symbol = TOKEN_SYMBOL;
uint8 public constant decimals = TOKEN_DECIMALS;
uint256 public constant INITIAL_SUPPLY = TOKEN_AMOUNT * (10 ** uint256(decimals));
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
}
文件 8 的 14:MintableToken.sol
pragma solidity ^0.4.23;
import "./Ownable.sol";
import "./StandardToken.sol";
contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished, "Minting has been finished");
_;
}
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
文件 9 的 14:Ownable.sol
pragma solidity ^0.4.23;
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Sender is not the owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "New owner address is invalid");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
}
文件 10 的 14:Pausable.sol
pragma solidity ^0.4.23;
import "./Ownable.sol";
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused, "Contract has been paused");
_;
}
modifier whenPaused() {
require(paused, "Contract has not been paused");
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
文件 11 的 14:PausableToken.sol
pragma solidity ^0.4.23;
import "./StandardToken.sol";
import "./Pausable.sol";
contract PausableToken is StandardToken, Pausable {
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
return super.transferFrom(_from, _to, _value);
}
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
return super.approve(_spender, _value);
}
function increaseApproval(address _spender, uint _addedValue) public whenNotPaused returns (bool success) {
return super.increaseApproval(_spender, _addedValue);
}
function decreaseApproval(address _spender, uint _subtractedValue) public whenNotPaused returns (bool success) {
return super.decreaseApproval(_spender, _subtractedValue);
}
}
文件 12 的 14:SafeMath.sol
pragma solidity ^0.4.23;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
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 c) {
c = a + b;
assert(c >= a);
return c;
}
}
文件 13 的 14:StandardToken.sol
pragma solidity ^0.4.23;
import "./BasicToken.sol";
import "./ERC20.sol";
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0), "Address to transfer to is invalid");
require(_value <= balances[_from], "Not enough balance");
require(_value <= allowed[_from][msg.sender], "Not enough allowance");
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) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
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 returns (bool) {
uint 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;
}
}
文件 14 的 14:TransferableToken.sol
pragma solidity ^0.4.23;
import "./Ownable.sol";
import "./StandardToken.sol";
contract TransferableToken is StandardToken, Ownable {
bool public isLocked;
mapping (address => bool) public transferableAddresses;
mapping (address => bool) public receivableAddresses;
constructor() public {
isLocked = true;
}
event Unlock();
event TransferableAddressAdded(address indexed addr);
event TransferableAddressRemoved(address indexed addr);
event ReceivableAddressAdded(address indexed addr);
event ReceivableAddressRemoved(address indexed addr);
function unlock() public onlyOwner {
isLocked = false;
emit Unlock();
}
function isTransferable(address addr) public view returns(bool) {
return !isLocked || transferableAddresses[addr];
}
function isReceivable(address addr) public view returns(bool) {
return !isLocked || receivableAddresses[addr];
}
function addTransferableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (addTransferableAddress(addrs[i])) {
success = true;
}
}
}
function addReceivableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (addReceivableAddress(addrs[i])) {
success = true;
}
}
}
function addTransferableAddress(address addr) public onlyOwner returns(bool success) {
if (!transferableAddresses[addr]) {
transferableAddresses[addr] = true;
emit TransferableAddressAdded(addr);
success = true;
}
}
function addReceivableAddress(address addr) public onlyOwner returns(bool success) {
if (!receivableAddresses[addr]) {
receivableAddresses[addr] = true;
emit ReceivableAddressAdded(addr);
success = true;
}
}
function removeTransferableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (removeTransferableAddress(addrs[i])) {
success = true;
}
}
}
function removeReceivableAddresses(address[] addrs) public onlyOwner returns(bool success) {
for (uint256 i = 0; i < addrs.length; i++) {
if (removeReceivableAddress(addrs[i])) {
success = true;
}
}
}
function removeTransferableAddress(address addr) public onlyOwner returns(bool success) {
if (transferableAddresses[addr]) {
transferableAddresses[addr] = false;
emit TransferableAddressRemoved(addr);
success = true;
}
}
function removeReceivableAddress(address addr) public onlyOwner returns(bool success) {
if (receivableAddresses[addr]) {
receivableAddresses[addr] = false;
emit ReceivableAddressRemoved(addr);
success = true;
}
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(isTransferable(_from) || isReceivable(_to), "From address not transferable and To address not receivable");
return super.transferFrom(_from, _to, _value);
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(isTransferable(msg.sender) || isReceivable(_to), "Sender not transferable and To address not receivable");
return super.transfer(_to, _value);
}
}
{
"compilationTarget": {
"MainToken.sol": "MainToken"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"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":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","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":"addr","type":"address"}],"name":"isTransferable","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"addFreezableAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"addReceivableAddresses","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"removeFreezableAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"INITIAL_SUPPLY","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"addTransferableAddresses","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":"addr","type":"address"}],"name":"addTransferableAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"addFreezableAddresses","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"removeReceivableAddresses","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"removeReceivableAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"removeTransferableAddresses","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"receivableAddresses","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"addReceivableAddress","outputs":[{"name":"success","type":"bool"}],"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":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","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":"addr","type":"address"}],"name":"isReceivable","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":true,"inputs":[{"name":"","type":"address"}],"name":"transferableAddresses","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isLocked","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addr","type":"address"}],"name":"removeTransferableAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"freezeAddresses","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addrs","type":"address[]"}],"name":"removeFreezableAddresses","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"TransferableAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"TransferableAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"ReceivableAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"ReceivableAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"FreezableAddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"addr","type":"address"}],"name":"FreezableAddressRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","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":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","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"}]