文件 1 的 7:Context.sol
pragma solidity >=0.6.0 <0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 2 的 7:ERC20.sol
pragma solidity >=0.6.0 <0.8.0;
import "../../GSN/Context.sol";
import "./IERC20.sol";
import "../../math/SafeMath.sol";
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
constructor (string memory name_, string memory symbol_) public {
_name = name_;
_symbol = symbol_;
_decimals = 18;
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
文件 3 的 7:ERC20Burnable.sol
pragma solidity >=0.6.0 <0.8.0;
import "../../GSN/Context.sol";
import "./ERC20.sol";
abstract contract ERC20Burnable is Context, ERC20 {
using SafeMath for uint256;
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
}
文件 4 的 7:IERC20.sol
pragma solidity >=0.6.0 <0.8.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);
}
文件 5 的 7:NFTToken.sol
pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;
struct VestingWallet {
address wallet;
uint256 totalAmount;
uint256 dayAmount;
uint256 startDay;
uint256 afterDays;
uint256 firstMonthAmount;
}
struct VestingType {
uint256 dailyRate;
uint256 afterDays;
uint256 firstMonthDailyUnlock;
}
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
contract NFTToken is Ownable, ERC20Burnable {
using SafeMath for uint256;
mapping (address => VestingWallet[]) public vestingWallets;
VestingType[] public vestingTypes;
uint256 public constant PRECISION = 1e18;
uint256 public constant ONE_HUNDRED_PERCENT = PRECISION * 100;
constructor() ERC20("NFT.TECH", "NFTT") {
vestingTypes.push(VestingType(287878787878787879, 0, 166666666666666667));
vestingTypes.push(VestingType(395833333333333333, 0, 166666666666666667));
vestingTypes.push(VestingType(633333333333333333, 0, 166666666666666667));
vestingTypes.push(VestingType(100000000000000000000, 360 days, 100000000000000000000));
vestingTypes.push(VestingType(277777777777777778, 540 days, 277777777777777778));
vestingTypes.push(VestingType(277777777777777778, 30 days, 277777777777777778));
_mint(address(0x9aE9127cFDB6Aa1843DD182E8270D24735937485), 60000000e18);
_mint(address(0x9aE9127cFDB6Aa1843DD182E8270D24735937485), 407868975879848000000000);
_mint(address(0xB74e94301CbE45A0A79527C12121D2697D9d6223), 5000000e18);
}
function getListingTime() public pure returns (uint256) {
return 1634824800;
}
function getMaxTotalSupply() public pure returns (uint256) {
return PRECISION * 157000000;
}
function mulDiv(uint256 x, uint256 y, uint256 z) private pure returns (uint256) {
return x.mul(y).div(z);
}
function addAllocations(address[] memory addresses, uint256[] memory totalAmounts, uint256 vestingTypeIndex) external onlyOwner returns (bool) {
require(addresses.length == totalAmounts.length, "Address and totalAmounts length must be same");
require(vestingTypeIndex < vestingTypes.length, "Vesting type isnt found");
VestingType memory vestingType = vestingTypes[vestingTypeIndex];
uint256 addressesLength = addresses.length;
for(uint256 i = 0; i < addressesLength; i++) {
address _address = addresses[i];
uint256 totalAmount = totalAmounts[i];
uint256 dayAmount = mulDiv(totalAmounts[i], vestingType.dailyRate, ONE_HUNDRED_PERCENT);
uint256 afterDay = vestingType.afterDays;
uint256 firstMonthAmount = mulDiv(totalAmounts[i], vestingType.firstMonthDailyUnlock, ONE_HUNDRED_PERCENT).mul(30);
addVestingWallet(_address, totalAmount, dayAmount, afterDay, firstMonthAmount);
}
return true;
}
function _mint(address account, uint256 amount) internal override {
uint256 totalSupply = super.totalSupply();
require(getMaxTotalSupply() >= totalSupply.add(amount), "Maximum supply exceeded!");
super._mint(account, amount);
}
function addVestingWallet(address wallet, uint256 totalAmount, uint256 dayAmount, uint256 afterDays, uint256 firstMonthAmount) internal {
uint256 releaseTime = getListingTime();
VestingWallet memory vestingWallet = VestingWallet(
wallet,
totalAmount,
dayAmount,
releaseTime.add(afterDays),
afterDays,
firstMonthAmount
);
vestingWallets[wallet].push(vestingWallet);
_mint(wallet, totalAmount);
}
function getTimestamp() external view returns (uint256) {
return block.timestamp;
}
function getDays(uint256 afterDays) public view returns (uint256) {
uint256 releaseTime = getListingTime();
uint256 time = releaseTime.add(afterDays);
if (block.timestamp < time) {
return 0;
}
uint256 diff = block.timestamp.sub(time);
uint256 ds = diff.div(1 days).add(1);
return ds;
}
function isStarted(uint256 startDay) public view returns (bool) {
uint256 releaseTime = getListingTime();
if (block.timestamp < releaseTime || block.timestamp < startDay) {
return false;
}
return true;
}
function getUnlockedVestingAmount(address sender) public view returns (uint256) {
if (!isStarted(0)) {
return 0;
}
uint256 dailyTransferableAmount = 0;
for (uint256 i=0; i<vestingWallets[sender].length; i++) {
if (vestingWallets[sender][i].totalAmount == 0) {
continue;
}
uint256 trueDays = getDays(vestingWallets[sender][i].afterDays);
uint256 dailyTransferableAmountCurrent = 0;
if (trueDays > 0 && trueDays < 30) {
trueDays = 30;
dailyTransferableAmountCurrent = vestingWallets[sender][i].firstMonthAmount;
}
if (trueDays >= 30) {
dailyTransferableAmountCurrent = vestingWallets[sender][i].firstMonthAmount.add(vestingWallets[sender][i].dayAmount.mul(trueDays.sub(30)));
}
if (dailyTransferableAmountCurrent > vestingWallets[sender][i].totalAmount) {
dailyTransferableAmountCurrent = vestingWallets[sender][i].totalAmount;
}
dailyTransferableAmount = dailyTransferableAmount.add(dailyTransferableAmountCurrent);
}
return dailyTransferableAmount;
}
function getTotalVestedAmount(address sender) public view returns (uint256) {
uint256 totalAmount = 0;
for (uint256 i=0; i<vestingWallets[sender].length; i++) {
totalAmount = totalAmount.add(vestingWallets[sender][i].totalAmount);
}
return totalAmount;
}
function getRestAmount(address sender) public view returns (uint256) {
uint256 transferableAmount = getUnlockedVestingAmount(sender);
uint256 totalAmount = getTotalVestedAmount(sender);
uint256 restAmount = totalAmount.sub(transferableAmount);
return restAmount;
}
function canTransfer(address sender, uint256 amount) public view returns (bool) {
if (vestingWallets[sender].length == 0) {
return true;
}
uint256 balance = balanceOf(sender);
uint256 restAmount = getRestAmount(sender);
uint256 totalAmount = getTotalVestedAmount(sender);
if (balance > totalAmount && balance.sub(totalAmount) >= amount) {
return true;
}
if (balance.sub(amount) < restAmount) {
return false;
}
return true;
}
function _beforeTokenTransfer(address sender, address recipient, uint256 amount) internal virtual override(ERC20) {
require(canTransfer(sender, amount), "Unable to transfer, not unlocked yet.");
super._beforeTokenTransfer(sender, recipient, amount);
}
}
文件 6 的 7:Ownable.sol
pragma solidity >=0.6.0 <0.8.0;
import "../GSN/Context.sol";
abstract 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(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 7 的 7:SafeMath.sol
pragma solidity >=0.6.0 <0.8.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": {
"contracts/NFTToken.sol": "NFTToken"
},
"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":"owner","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":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","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"},{"inputs":[],"name":"ONE_HUNDRED_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"totalAmounts","type":"uint256[]"},{"internalType":"uint256","name":"vestingTypeIndex","type":"uint256"}],"name":"addAllocations","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","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":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"canTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"afterDays","type":"uint256"}],"name":"getDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getListingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getMaxTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"getRestAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"getTotalVestedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"getUnlockedVestingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"startDay","type":"uint256"}],"name":"isStarted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","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":"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":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vestingTypes","outputs":[{"internalType":"uint256","name":"dailyRate","type":"uint256"},{"internalType":"uint256","name":"afterDays","type":"uint256"},{"internalType":"uint256","name":"firstMonthDailyUnlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"vestingWallets","outputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"dayAmount","type":"uint256"},{"internalType":"uint256","name":"startDay","type":"uint256"},{"internalType":"uint256","name":"afterDays","type":"uint256"},{"internalType":"uint256","name":"firstMonthAmount","type":"uint256"}],"stateMutability":"view","type":"function"}]