文件 1 的 5:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
文件 2 的 5:ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC20Metadata.sol";
import "./Context.sol";
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view virtual 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);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
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);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += 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 += amount;
_balances[account] += 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);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= 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 _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
文件 3 的 5:FON.sol
pragma solidity ^0.8.0;
import "./ERC20.sol";
contract FON is ERC20 {
address public admin;
address public receiver;
address public fon721maker;
address public stake;
address public distributor;
address public fon721;
address public auction;
address public ticket;
uint public stakeFeePercentage;
uint public fon721Fee;
uint public ownPercentage;
uint public exitPercentage;
uint public auctionFeePercentage;
uint public auctionMinterFeePercentage;
mapping(address => bool) public minters;
mapping(address => bool) public allowed721;
mapping(address => bool) public auctionMinters;
event NewAdmin(address indexed newAdmin);
event NewReceiver(address indexed newReceiver);
event NewFON721Maker(address indexed newFON721Maker);
event NewStake(address indexed newStake);
event NewDistributor(address indexed newDistributor);
event NewFON721(address indexed newFON721);
event NewAllowed721(address indexed newAllowed721, bool isAllowed);
event NewMinter(address indexed newMinter, bool isMinter);
event NewAuction(address indexed newAuction);
event NewTicket(address indexed newTicket);
event NewAuctionMinter(address indexed newAuctionMinter);
event NewAuctionMinterFeePercentage(uint newAuctionMinterFeePercentage);
event NewStakeFeePercentage(uint newStakeFeePercentage);
event NewFON721Fee(uint newFON721Fee);
event NewOwnPercentage(uint newOwnPercentage);
event NewExitPercentage(uint newExitPercentage);
event NewAuctionFeePercentage(uint newAuctionFeePercentage);
constructor(
address newAdmin,
address newReceiver,
string memory name,
string memory symbol,
uint newOwnPercentage,
uint newExitPercentage,
uint newStakeFeePercentage,
uint newAuctionFeePercentage,
uint newAuctionMinterFeePercentage,
uint newFON721Fee
) ERC20(name, symbol) {
require(newAdmin != address(0) && newReceiver != address(0), "FON: zero address");
admin = newAdmin;
receiver = newReceiver;
ownPercentage = newOwnPercentage;
exitPercentage = newExitPercentage;
stakeFeePercentage = newStakeFeePercentage;
auctionFeePercentage = newAuctionFeePercentage;
auctionMinterFeePercentage = newAuctionMinterFeePercentage;
fon721Fee = newFON721Fee;
}
function setOwnPercentage(uint newOwnPercentage) external {
require(msg.sender == admin, "FON: admin");
require(
newOwnPercentage > 0.5e18 && newOwnPercentage < exitPercentage,
"FON: own percentage"
);
ownPercentage = newOwnPercentage;
emit NewOwnPercentage(ownPercentage);
}
function setStakeFeePercentage(uint newStakeFeePercentage) external {
require(msg.sender == admin, "FON: admin");
stakeFeePercentage = newStakeFeePercentage;
emit NewStakeFeePercentage(stakeFeePercentage);
}
function setAuctionFeePercentage(uint newAuctionFeePercentage) external {
require(msg.sender == admin, "FON: admin");
auctionFeePercentage = newAuctionFeePercentage;
emit NewAuctionFeePercentage(auctionFeePercentage);
}
function setAuctionMinterFeePercentage(uint newAuctionMinterFeePercentage) external {
require(msg.sender == admin, "FON: admin");
auctionMinterFeePercentage = newAuctionMinterFeePercentage;
emit NewAuctionMinterFeePercentage(auctionMinterFeePercentage);
}
function setFON721Fee(uint newFON721Fee) external {
require(msg.sender == admin, "FON: admin");
fon721Fee = newFON721Fee;
emit NewFON721Fee(newFON721Fee);
}
function setMinter(address minterAddress) public {
require(msg.sender == admin, "FON: admin");
minters[minterAddress] = !minters[minterAddress];
emit NewMinter(minterAddress, minters[minterAddress]);
}
function setAuctionMinter(address newAuctionMinter) external {
require(msg.sender == admin, "FON: admin");
require(newAuctionMinter != address(0), "FON: zero address");
auctionMinters[newAuctionMinter] = !auctionMinters[newAuctionMinter];
emit NewAuctionMinter(newAuctionMinter);
}
function setAllowed721(address allowed721Address) public {
require(msg.sender == admin, "FON: admin");
allowed721[allowed721Address] = !allowed721[allowed721Address];
emit NewAllowed721(allowed721Address, allowed721[allowed721Address]);
}
function setExitPercentage(uint newExitPercentage) external {
require(msg.sender == admin, "FON: admin");
require(newExitPercentage > ownPercentage, "FON: exit percentage");
exitPercentage = newExitPercentage;
emit NewExitPercentage(exitPercentage);
}
function setAdmin(address newAdmin) external {
require(msg.sender == admin, "FON: admin");
require(newAdmin != address(0), "FON: zero address");
admin = newAdmin;
emit NewAdmin(admin);
}
function setReceiver(address newReceiver) external {
require(msg.sender == admin, "FON: admin");
require(newReceiver != address(0), "FON: zero address");
receiver = newReceiver;
emit NewReceiver(receiver);
}
function setFON721Maker(address newFON721Maker) external {
require(msg.sender == admin, "FON: admin");
require(newFON721Maker != address(0), "FON: zero address");
setMinter(fon721maker);
fon721maker = newFON721Maker;
setMinter(fon721maker);
emit NewFON721Maker(fon721maker);
}
function setStake(address newStake) external {
require(msg.sender == admin, "FON: admin");
require(newStake != address(0), "FON: zero address");
stake = newStake;
emit NewStake(stake);
}
function setDistributor(address newDistributor) external {
require(msg.sender == admin, "FON: admin");
require(newDistributor != address(0), "FON: zero address");
setMinter(distributor);
distributor = newDistributor;
setMinter(distributor);
emit NewDistributor(distributor);
}
function setFON721(address newFON721) external {
require(msg.sender == admin, "FON: admin");
require(newFON721 != address(0), "FON: zero address");
setAllowed721(fon721);
fon721 = newFON721;
setAllowed721(fon721);
emit NewFON721(fon721);
}
function setAuction(address newAuction) external {
require(msg.sender == admin, "FON: admin");
require(newAuction != address(0), "FON: zero address");
setMinter(auction);
auction = newAuction;
setMinter(auction);
emit NewAuction(auction);
}
function setTicket(address newTicket) external {
require(msg.sender == admin, "FON: admin");
require(newTicket != address(0), "FON: zero address");
setMinter(ticket);
ticket = newTicket;
setMinter(ticket);
emit NewTicket(ticket);
}
function mint(address to, uint amount) external {
require(minters[msg.sender], "FON: minter");
_mint(to, amount);
}
}
文件 4 的 5:IERC20.sol
pragma solidity ^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 的 5:IERC20Metadata.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
{
"compilationTarget": {
"FON.sol": "FON"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"address","name":"newReceiver","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"newOwnPercentage","type":"uint256"},{"internalType":"uint256","name":"newExitPercentage","type":"uint256"},{"internalType":"uint256","name":"newStakeFeePercentage","type":"uint256"},{"internalType":"uint256","name":"newAuctionFeePercentage","type":"uint256"},{"internalType":"uint256","name":"newAuctionMinterFeePercentage","type":"uint256"},{"internalType":"uint256","name":"newFON721Fee","type":"uint256"}],"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":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAllowed721","type":"address"},{"indexed":false,"internalType":"bool","name":"isAllowed","type":"bool"}],"name":"NewAllowed721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAuction","type":"address"}],"name":"NewAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAuctionFeePercentage","type":"uint256"}],"name":"NewAuctionFeePercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAuctionMinter","type":"address"}],"name":"NewAuctionMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAuctionMinterFeePercentage","type":"uint256"}],"name":"NewAuctionMinterFeePercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newDistributor","type":"address"}],"name":"NewDistributor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newExitPercentage","type":"uint256"}],"name":"NewExitPercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newFON721","type":"address"}],"name":"NewFON721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newFON721Fee","type":"uint256"}],"name":"NewFON721Fee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newFON721Maker","type":"address"}],"name":"NewFON721Maker","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newMinter","type":"address"},{"indexed":false,"internalType":"bool","name":"isMinter","type":"bool"}],"name":"NewMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newOwnPercentage","type":"uint256"}],"name":"NewOwnPercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newReceiver","type":"address"}],"name":"NewReceiver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newStake","type":"address"}],"name":"NewStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newStakeFeePercentage","type":"uint256"}],"name":"NewStakeFeePercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newTicket","type":"address"}],"name":"NewTicket","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":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"","type":"address"}],"name":"allowed721","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[],"name":"auction","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionMinterFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"auctionMinters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","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":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distributor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exitPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fon721","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fon721Fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fon721maker","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minters","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":"ownPercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"allowed721Address","type":"address"}],"name":"setAllowed721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAuction","type":"address"}],"name":"setAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAuctionFeePercentage","type":"uint256"}],"name":"setAuctionFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAuctionMinter","type":"address"}],"name":"setAuctionMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAuctionMinterFeePercentage","type":"uint256"}],"name":"setAuctionMinterFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newDistributor","type":"address"}],"name":"setDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newExitPercentage","type":"uint256"}],"name":"setExitPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFON721","type":"address"}],"name":"setFON721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newFON721Fee","type":"uint256"}],"name":"setFON721Fee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newFON721Maker","type":"address"}],"name":"setFON721Maker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"minterAddress","type":"address"}],"name":"setMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newOwnPercentage","type":"uint256"}],"name":"setOwnPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newReceiver","type":"address"}],"name":"setReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newStake","type":"address"}],"name":"setStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newStakeFeePercentage","type":"uint256"}],"name":"setStakeFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTicket","type":"address"}],"name":"setTicket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stake","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakeFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticket","outputs":[{"internalType":"address","name":"","type":"address"}],"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"}]