文件 1 的 7:burnable.sol
pragma solidity ^0.5.8;
import "./erc20.sol";
contract ERC20Burnable is ERC20 {
function burn(uint256 value) external {
_burn(msg.sender, value);
}
function burnFrom(address from, uint256 value) external {
_burnFrom(from, value);
}
}
文件 2 的 7:erc20.sol
pragma solidity ^0.5.8;
import "./safemath.sol";
import "./ierc20.sol";
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) internal _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) external view returns (uint256) {
return _balances[owner];
}
function allowance(address owner, address spender) external view returns (uint256) {
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) external returns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowed[from][msg.sender].sub(value));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
_approve(msg.sender, spender, _allowed[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
_approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue));
return true;
}
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0), "ERC20: transfer to the zero address");
require(_balances[from]>=value, "ERC20 transfer: not enough tokens");
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
require(_balances[account] >= value, "Burn: not enough tokens");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowed[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _burnFrom(address account, uint256 value) internal {
require(_allowed[account][msg.sender]>=value, "Burn: allowance too low");
_burn(account, value);
_approve(account, msg.sender, _allowed[account][msg.sender].sub(value));
}
}
文件 3 的 7:ierc20.sol
pragma solidity ^0.5.8;
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 4 的 7:ownable.sol
pragma solidity ^0.5.8;
contract Ownable {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return msg.sender == owner;
}
function renounceOwnership() external onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
function transferOwnership(address _newOwner) external onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public{
require (newOwner == msg.sender, "Ownable: only new Owner can accept");
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
文件 5 的 7:safemath.sol
pragma solidity ^0.5.7;
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, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
文件 6 的 7:timelocks.sol
pragma solidity ^0.5.8;
import "./erc20.sol";
import "./ownable.sol";
contract Timelocks is ERC20, Ownable{
uint public lockedBalance;
struct Locker {
uint amount;
uint locktime;
}
mapping(address => Locker[]) timeLocks;
function lock(uint lockTimestamp, uint amount, address user) external onlyOwner {
_lock(lockTimestamp, amount, user);
}
function _lock(uint lockTimestamp, uint amount, address user) internal{
uint current = _balances[address(this)];
require(amount <= current.sub(lockedBalance), "Lock: Not enough tokens");
lockedBalance = lockedBalance.add(amount);
timeLocks[user].push(Locker(amount, lockTimestamp));
}
function unlock() external
{
require(timeLocks[msg.sender].length > 0, "Unlock: No locks!");
Locker[] storage l = timeLocks[msg.sender];
for (uint i = 0; i < l.length; i++)
{
if (l[i].locktime < block.timestamp) {
uint amount = l[i].amount;
require(amount <= lockedBalance && amount <= _balances[address(this)], "Unlock: Not enough coins on contract!");
lockedBalance = lockedBalance.sub(amount);
_transfer(address(this), msg.sender, amount);
for (uint j = i; j < l.length - 1; j++)
{
l[j] = l[j + 1];
}
l.length--;
i--;
}
}
}
function locks() external view returns(uint)
{
return _locks(msg.sender);
}
function locksOf(address user) external view returns(uint) {
return _locks(user);
}
function _locks(address user) internal view returns(uint){
return timeLocks[user].length;
}
function showLock(uint num) external view returns(uint, uint)
{
return _showLock(msg.sender, num);
}
function showLockOf(address user, uint num) external view returns(uint, uint) {
return _showLock(user, num);
}
function _showLock(address user, uint num) internal view returns(uint, uint) {
require(timeLocks[user].length > 0, "ShowLock: No locks!");
require(num < timeLocks[user].length, "ShowLock: Index over number of locks.");
Locker[] storage l = timeLocks[user];
return (l[num].amount, l[num].locktime);
}
}
文件 7 的 7:wolfs.sol
pragma solidity ^0.5.8;
import "./ierc20.sol";
import "./safemath.sol";
import "./erc20.sol";
import "./burnable.sol";
import "./ownable.sol";
import "./timelocks.sol";
contract ContractFallbacks {
function receiveApproval(address from, uint256 _amount, address _token, bytes memory _data) public;
function onTokenTransfer(address from, uint256 amount, bytes memory data) public returns (bool success);
}
contract Wolfs is IERC20, ERC20, ERC20Burnable, Ownable, Timelocks {
using SafeMath for uint256;
string public name;
string public symbol;
uint8 public decimals;
constructor () public {
name = "Wolfs Group AG";
symbol = "WLF";
decimals = 0;
owner = 0x7fd429DBb710674614A35e967788Fa3e23A5c1C9;
emit OwnershipTransferred(address(0), owner);
_mint(0xc7eEef150818b5D3301cc93a965195F449603805, 15000000);
_mint(0x7fd429DBb710674614A35e967788Fa3e23A5c1C9, 135000000);
}
function approveAndCall(address _spender, uint256 _amount, bytes calldata _extraData) external returns (bool success)
{
require(approve(_spender, _amount), "ERC20: Approve unsuccesfull");
ContractFallbacks(_spender).receiveApproval(msg.sender, _amount, address(this), _extraData);
return true;
}
function transferAndCall(address _to, uint _value, bytes calldata _data) external returns (bool success)
{
_transfer(msg.sender, _to, _value);
ContractFallbacks(_to).onTokenTransfer(msg.sender, _value, _data);
return true;
}
}
{
"compilationTarget": {
"wolfs.sol": "Wolfs"
},
"evmVersion": "petersburg",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"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":"num","type":"uint256"}],"name":"showLock","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":"spender","type":"address"},{"name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transferAndCall","outputs":[{"name":"success","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":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":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"value","type":"uint256"}],"name":"burnFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lockedBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","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":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"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":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":true,"inputs":[{"name":"user","type":"address"}],"name":"locksOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"lockTimestamp","type":"uint256"},{"name":"amount","type":"uint256"},{"name":"user","type":"address"}],"name":"lock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","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":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"locks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"num","type":"uint256"}],"name":"showLockOf","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"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":"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"}]