文件 1 的 12: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 的 12:EMatesMinter.sol
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IEMatesMinter.sol";
contract EMatesMinter is Ownable, IEMatesMinter {
IEMates public immutable emates;
IEthereumMix public immutable emix;
uint256 public mintPrice;
uint256 public limit;
constructor(
IEMates _emates,
IEthereumMix _emix,
uint256 _mintPrice
) {
emates = _emates;
emix = _emix;
mintPrice = _mintPrice;
emit SetMintPrice(_mintPrice);
}
function setLimit(uint256 _limit) external onlyOwner {
limit = _limit;
emit SetLimit(_limit);
}
function setMintPrice(uint256 _price) external onlyOwner {
mintPrice = _price;
emit SetMintPrice(_price);
}
function mint() public returns (uint256 id) {
require(emates.totalSupply() < limit, "EMatesMinter: Limit exceeded");
id = emates.mint(msg.sender);
emix.transferFrom(msg.sender, address(this), mintPrice);
}
function mintWithPermit(
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 id) {
emix.permit(msg.sender, address(this), mintPrice, deadline, v, r, s);
id = mint();
}
function withdrawEmix() external onlyOwner {
emix.transfer(msg.sender, emix.balanceOf(address(this)));
}
}
文件 3 的 12:IEMates.sol
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "./IERC2981.sol";
interface IEMates is IERC721, IERC721Metadata, IERC2981 {
event SetMinter(address indexed target, bool indexed isMinter);
event SetRoyaltyInfo(address indexed receiver, uint256 fee);
event SetContractURI(string uri);
event SetBaseURI(string uri);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external view returns (bytes32);
function PERMIT_ALL_TYPEHASH() external view returns (bytes32);
function nonces(uint256 id) external view returns (uint256);
function noncesForAll(address owner) external view returns (uint256);
function totalSupply() external view returns (uint256);
function isMinter(address target) external view returns (bool);
function feeReceiver() external view returns (address);
function fee() external view returns (uint256);
function contractURI() external view returns (string calldata);
function permit(
address spender,
uint256 id,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function permitAll(
address owner,
address spender,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function mint(address to) external returns (uint256 id);
function mintBatch(uint256 limit) external;
}
文件 4 的 12:IEMatesMinter.sol
pragma solidity ^0.8.9;
import "./IEMates.sol";
import "./IEthereumMix.sol";
interface IEMatesMinter {
event SetMintPrice(uint256 mintPrice);
event SetLimit(uint256 limit);
function emates() external view returns (IEMates);
function emix() external view returns (IEthereumMix);
function mintPrice() external view returns (uint256);
function limit() external view returns (uint256);
function mint() external returns (uint256 id);
function mintWithPermit(
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 id);
}
文件 5 的 12:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 6 的 12: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);
}
文件 7 的 12:IERC2981.sol
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface IERC2981 is IERC165 {
function royaltyInfo(uint256 _tokenId, uint256 _salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
文件 8 的 12:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function setApprovalForAll(address operator, bool _approved) external;
function isApprovedForAll(address owner, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
文件 9 的 12:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 10 的 12:IEthereumMix.sol
pragma solidity ^0.8.9;
import "./IFungibleToken.sol";
interface IEthereumMix is IFungibleToken {
event SetSigner(address indexed signer);
event SendOverHorizon(address indexed sender, uint256 indexed toChain, address indexed receiver, uint256 sendId, uint256 amount);
event ReceiveOverHorizon(address indexed receiver, uint256 indexed fromChain, address indexed sender, uint256 sendId, uint256 amount);
function signer() external view returns (address);
function sendOverHorizon(uint256 toChain, address receiver, uint256 amount) external returns (uint256 sendId);
function sended(address sender, uint256 toChain, address receiver, uint256 sendId) external view returns (uint256 amount);
function sendCount(address sender, uint256 toChain, address receiver) external view returns (uint256);
function receiveOverHorizon(uint256 fromChain, uint256 toChain, address sender, uint256 sendId, uint256 amount, bytes calldata signature) external;
function received(address receiver, uint256 fromChain, address sender, uint256 sendId) external view returns (bool);
}
文件 11 的 12:IFungibleToken.sol
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IFungibleToken is IERC20 {
function version() external view returns (string memory);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external view returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
文件 12 的 12: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() {
_setOwner(_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 {
_setOwner(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/EMatesMinter.sol": "EMatesMinter"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IEMates","name":"_emates","type":"address"},{"internalType":"contract IEthereumMix","name":"_emix","type":"address"},{"internalType":"uint256","name":"_mintPrice","type":"uint256"}],"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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"SetLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mintPrice","type":"uint256"}],"name":"SetMintPrice","type":"event"},{"inputs":[],"name":"emates","outputs":[{"internalType":"contract IEMates","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emix","outputs":[{"internalType":"contract IEthereumMix","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mint","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"mintWithPermit","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"setLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setMintPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawEmix","outputs":[],"stateMutability":"nonpayable","type":"function"}]