pragma solidity ^0.4.25;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
}
contract Pausable is Ownable {
bool public paused;
event Paused(address account);
event Unpaused(address account);
constructor() internal {
paused = false;
}
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() public onlyOwner whenNotPaused {
paused = true;
emit Paused(msg.sender);
}
function unpause() public onlyOwner whenPaused {
paused = false;
emit Unpaused(msg.sender);
}
}
contract BaseToken is Pausable {
using SafeMath for uint256;
string constant public name = 'Unipig';
string constant public symbol = 'PIGI';
uint8 constant public decimals = 18;
uint256 public totalSupply = 2.1e25;
uint256 constant public _totalLimit = 1e32;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function _transfer(address from, address to, uint value) internal {
require(to != address(0));
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
require(account != address(0));
totalSupply = totalSupply.add(value);
require(_totalLimit >= totalSupply);
balanceOf[account] = balanceOf[account].add(value);
emit Transfer(address(0), account, value);
}
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
_transfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public whenNotPaused returns (bool) {
require(spender != address(0));
allowance[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
require(spender != address(0));
allowance[msg.sender][spender] = allowance[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, allowance[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) {
require(spender != address(0));
allowance[msg.sender][spender] = allowance[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, allowance[msg.sender][spender]);
return true;
}
}
contract BurnToken is BaseToken {
event Burn(address indexed from, uint256 value);
function burn(uint256 value) public whenNotPaused returns (bool) {
balanceOf[msg.sender] = balanceOf[msg.sender].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(msg.sender, value);
return true;
}
function burnFrom(address from, uint256 value) public whenNotPaused returns (bool) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Burn(from, value);
return true;
}
}
contract BatchToken is BaseToken {
function batchTransfer(address[] addressList, uint256[] amountList) public returns (bool) {
uint256 length = addressList.length;
require(addressList.length == amountList.length);
require(length > 0 && length <= 20);
for (uint256 i = 0; i < length; i++) {
transfer(addressList[i], amountList[i]);
}
return true;
}
}
contract LockToken is BaseToken {
struct LockItem {
uint256 endtime;
uint256 remain;
}
struct LockMeta {
uint8 lockType;
LockItem[] lockItems;
}
mapping (address => LockMeta) public lockData;
event Lock(address indexed lockAddress, uint8 indexed lockType, uint256[] endtimeList, uint256[] remainList);
function _transfer(address from, address to, uint value) internal {
uint8 lockType = lockData[from].lockType;
if (lockType != 0) {
uint256 remain = balanceOf[from].sub(value);
uint256 length = lockData[from].lockItems.length;
for (uint256 i = 0; i < length; i++) {
LockItem storage item = lockData[from].lockItems[i];
if (block.timestamp < item.endtime && remain < item.remain) {
revert();
}
}
}
super._transfer(from, to, value);
}
function lock(address lockAddress, uint8 lockType, uint256[] endtimeList, uint256[] remainList) public onlyOwner returns (bool) {
require(lockAddress != address(0));
require(lockType == 0 || lockType == 1 || lockType == 2);
require(lockData[lockAddress].lockType != 1);
lockData[lockAddress].lockItems.length = 0;
lockData[lockAddress].lockType = lockType;
if (lockType == 0) {
emit Lock(lockAddress, lockType, endtimeList, remainList);
return true;
}
require(endtimeList.length == remainList.length);
uint256 length = endtimeList.length;
require(length > 0 && length <= 12);
uint256 thisEndtime = endtimeList[0];
uint256 thisRemain = remainList[0];
lockData[lockAddress].lockItems.push(LockItem({endtime: thisEndtime, remain: thisRemain}));
for (uint256 i = 1; i < length; i++) {
require(endtimeList[i] > thisEndtime && remainList[i] < thisRemain);
lockData[lockAddress].lockItems.push(LockItem({endtime: endtimeList[i], remain: remainList[i]}));
thisEndtime = endtimeList[i];
thisRemain = remainList[i];
}
emit Lock(lockAddress, lockType, endtimeList, remainList);
return true;
}
}
contract AirdropToken is BaseToken {
uint256 constant public airMax = 0;
uint256 public airTotal = 0;
uint256 public airBegintime = 1600475143;
uint256 public airEndtime = 1601395200;
uint256 public airOnce = 0;
uint256 public airLimitCount = 3;
mapping (address => uint256) public airCountOf;
event Airdrop(address indexed from, uint256 indexed count, uint256 tokenValue);
event AirdropSetting(uint256 airBegintime, uint256 airEndtime, uint256 airOnce, uint256 airLimitCount);
function airdrop() public payable {
require(block.timestamp >= airBegintime && block.timestamp <= airEndtime);
require(msg.value == 0);
require(airOnce > 0);
airTotal = airTotal.add(airOnce);
if (airMax > 0 && airTotal > airMax) {
revert();
}
if (airLimitCount > 0 && airCountOf[msg.sender] >= airLimitCount) {
revert();
}
_mint(msg.sender, airOnce);
airCountOf[msg.sender] = airCountOf[msg.sender].add(1);
emit Airdrop(msg.sender, airCountOf[msg.sender], airOnce);
}
function changeAirdropSetting(uint256 newAirBegintime, uint256 newAirEndtime, uint256 newAirOnce, uint256 newAirLimitCount) public onlyOwner {
airBegintime = newAirBegintime;
airEndtime = newAirEndtime;
airOnce = newAirOnce;
airLimitCount = newAirLimitCount;
emit AirdropSetting(newAirBegintime, newAirEndtime, newAirOnce, newAirLimitCount);
}
}
contract CustomToken is BaseToken, BurnToken, BatchToken, LockToken, AirdropToken {
constructor() public {
balanceOf[0x3157ccB761242c8F7218Db1c525e607A1df5f36d] = totalSupply;
emit Transfer(address(0), 0x3157ccB761242c8F7218Db1c525e607A1df5f36d, totalSupply);
owner = 0x3157ccB761242c8F7218Db1c525e607A1df5f36d;
}
function() public payable {
airdrop();
}
}
{
"compilationTarget": {
"CustomToken.sol": "CustomToken"
},
"evmVersion": "byzantium",
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"constant":true,"inputs":[],"name":"airMax","outputs":[{"name":"","type":"uint256"}],"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":"airTotal","outputs":[{"name":"","type":"uint256"}],"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":"newAirBegintime","type":"uint256"},{"name":"newAirEndtime","type":"uint256"},{"name":"newAirOnce","type":"uint256"},{"name":"newAirLimitCount","type":"uint256"}],"name":"changeAirdropSetting","outputs":[],"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":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"airdrop","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"_totalLimit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"lockAddress","type":"address"},{"name":"lockType","type":"uint8"},{"name":"endtimeList","type":"uint256[]"},{"name":"remainList","type":"uint256[]"}],"name":"lock","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"burn","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","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":"from","type":"address"},{"name":"value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addressList","type":"address[]"},{"name":"amountList","type":"uint256[]"}],"name":"batchTransfer","outputs":[{"name":"","type":"bool"}],"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":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"airCountOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"airOnce","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":true,"inputs":[],"name":"airEndtime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"airBegintime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"airLimitCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"lockData","outputs":[{"name":"lockType","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"count","type":"uint256"},{"indexed":false,"name":"tokenValue","type":"uint256"}],"name":"Airdrop","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"airBegintime","type":"uint256"},{"indexed":false,"name":"airEndtime","type":"uint256"},{"indexed":false,"name":"airOnce","type":"uint256"},{"indexed":false,"name":"airLimitCount","type":"uint256"}],"name":"AirdropSetting","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"lockAddress","type":"address"},{"indexed":true,"name":"lockType","type":"uint8"},{"indexed":false,"name":"endtimeList","type":"uint256[]"},{"indexed":false,"name":"remainList","type":"uint256[]"}],"name":"Lock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","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"},{"anonymous":false,"inputs":[{"indexed":false,"name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]