文件 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) {
return msg.data;
}
}
文件 2 的 5:FeudalzOrczSales.sol
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IGoldz.sol";
interface IFeudalzOrcz {
function mint(uint quantity, address receiver) external;
}
contract FeudalzOrczSales is Ownable {
IGoldz goldz = IGoldz(0x7bE647634A942e73F8492d15Ae492D867Ce5245c);
IFeudalzOrcz orcz = IFeudalzOrcz(0x60A0860503D9ECDA03436cA692D948319f5377f7);
bool public isSalesActive = true;
uint public price;
constructor() {
price = 40 ether;
}
function mint(uint quantity) external {
require(isSalesActive, "sale is not active");
goldz.transferFrom(msg.sender, address(this), price * quantity);
orcz.mint(quantity, msg.sender);
}
function toggleSales() external onlyOwner {
isSalesActive = !isSalesActive;
}
function setPrice(uint newPrice) external onlyOwner {
price = newPrice;
}
function burnGoldz() external onlyOwner {
uint balance = goldz.balanceOf(address(this));
goldz.burn(balance);
}
function withdrawGoldz() external onlyOwner {
uint amount = goldz.balanceOf(address(this));
goldz.transfer(msg.sender, amount);
}
}
文件 3 的 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);
}
文件 4 的 5:IGoldz.sol
pragma solidity ^0.8.2;
abstract contract IGoldz {
function burn(uint256 amount) public virtual;
function balanceOf(address account) public view virtual returns (uint256);
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual returns (bool);
function transfer(
address recipient,
uint256 amount
) public virtual returns (bool);
}
文件 5 的 5:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/FeudalzOrczSales.sol": "FeudalzOrczSales"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"burnGoldz","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isSalesActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleSales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawGoldz","outputs":[],"stateMutability":"nonpayable","type":"function"}]