// SPDX-License-Identifier: MIT
// Author: Grzegorz Kucmierz <gkucmierz@gmail.com>
// Source: https://github.com/gkucmierz/wisdom-contract
pragma solidity ^0.7.2;
contract ERC20 {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowed;
function _transfer(address sender, address recipient, uint256 amount) internal virtual returns (bool) {
require(balanceOf[sender] >= amount);
balanceOf[sender] -= amount;
balanceOf[recipient] += amount;
emit Transfer(sender, recipient, amount);
return true;
}
function transfer(address recipient, uint256 amount) public returns (bool) {
return _transfer(msg.sender, recipient, amount);
}
function allowance(address holder, address spender) public view returns (uint256) {
return allowed[holder][spender];
}
function approve(address spender, uint256 amount) public returns (bool) {
require(balanceOf[msg.sender] >= amount);
allowed[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
require(allowed[sender][msg.sender] >= amount);
_transfer(sender, recipient, amount);
allowed[sender][msg.sender] -= amount;
return true;
}
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed holder, address indexed spender, uint256 value);
}
interface IERC677Receiver {
function onTokenTransfer(address from, uint256 amount, bytes calldata data) external;
}
contract ERC667 is ERC20 {
function transferAndCall(address recipient, uint amount, bytes calldata data) public returns (bool) {
bool success = _transfer(msg.sender, recipient, amount);
if (success){
IERC677Receiver(recipient).onTokenTransfer(msg.sender, amount, data);
}
return success;
}
}
contract ERCTransferFrom is ERC667 {
mapping (address => mapping (address => uint256)) public nonceOf;
function _transfer(address from, address recipient, uint256 amount, uint256 nonce) private returns (bool) {
uint256 nextNonce = nonceOf[from][recipient] + 1;
require(nonce == nextNonce);
bool success = _transfer(from, recipient, amount);
if (success) nonceOf[from][recipient] = nextNonce;
return success;
}
function transferFrom(address recipient, uint256 amount, uint256 nonce, uint8 _v, bytes32 _r, bytes32 _s) public returns (bool) {
bytes32 hash = keccak256(abi.encodePacked('transferFrom', recipient, amount, nonce));
address from = ecrecover(hash, _v, _r, _s);
return _transfer(from, recipient, amount, nonce);
}
function transferFromUntil(address recipient, uint256 amount, uint256 untilBlock, uint256 nonce, uint8 _v, bytes32 _r, bytes32 _s) public returns (bool) {
require(untilBlock <= block.number);
bytes32 hash = keccak256(abi.encodePacked('transferFromUntil', recipient, amount, nonce, untilBlock));
address from = ecrecover(hash, _v, _r, _s);
return _transfer(from, recipient, amount, nonce);
}
}
contract Ownable {
address owner;
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0x0));
owner = newOwner;
emit TransferOwnership(newOwner);
}
event TransferOwnership(address newOwner);
}
contract Pausable is Ownable {
bool public paused = true;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
event Pause();
event Unpause();
}
contract Issuable is ERC20, Ownable {
bool locked = false;
modifier whenUnlocked() {
require(!locked);
_;
}
function issue(address[] memory addr, uint256[] memory amount) public onlyOwner whenUnlocked {
require(addr.length == amount.length);
uint8 i;
uint256 sum = 0;
for (i = 0; i < addr.length; ++i) {
balanceOf[addr[i]] = amount[i];
emit Transfer(address(0x0), addr[i], amount[i]);
sum += amount[i];
}
totalSupply += sum;
}
function lock() internal onlyOwner whenUnlocked {
locked = true;
}
}
contract WisdomToken is ERCTransferFrom, Pausable, Issuable {
constructor() {
name = 'Wisdom Token';
symbol = 'WIS';
decimals = 18;
totalSupply = 0;
}
function _transfer(address sender, address recipient, uint256 amount) internal whenNotPaused override returns (bool) {
return _transfer(sender, recipient, amount);
}
function alive(address owner) public {
lock();
unpause();
transferOwnership(owner);
}
}
{
"compilationTarget": {
"WisdomToken.sol": "WisdomToken"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","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":[],"name":"Pause","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"TransferOwnership","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"alive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addr","type":"address[]"},{"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"issue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"nonceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"transferAndCall","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"untilBlock","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"transferFromUntil","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]