编译器
0.8.20+commit.a1b79de6
文件 1 的 5:ClickCreatePrepay.sol
pragma solidity ^0.8.13;
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
contract ClickCreatePrepay is Ownable {
error NoErroneousPayments();
error IncorrectPrePayAmount();
error TooFewMints();
error NoPassOwned();
error PaymentFailed();
event MintDone(uint256 timestamp);
event PrepayPriceChanged(uint256 oldPrepayPrice, uint256 newPrepayPrice, uint256 timestamp);
event PrepayCreated(address indexed prepayUser, uint256 indexed prepayAmount, address indexed passContract, uint256 passTokenId, uint256 prepayPrice, uint256 timestamp);
address payable public prepayBeneficiary;
uint256 public prepayPrice;
uint256 public prepayMinMints = 1;
IERC1155 public passContract;
uint256 public passTokenId;
constructor(address _prepayBeneficiary, uint256 _prepayPrice, address _passContract, uint256 _passTokenId) {
prepayBeneficiary = payable(_prepayBeneficiary);
prepayPrice = _prepayPrice;
passContract = IERC1155(_passContract);
passTokenId = _passTokenId;
}
function createPrepay(address prepayUser, uint256 prepayAmount) external payable {
if (prepayAmount < prepayMinMints) {
revert TooFewMints();
}
if (msg.value != prepayPrice * prepayAmount || msg.value == 0) {
revert IncorrectPrePayAmount();
}
if (passContract.balanceOf(prepayUser, passTokenId) == 0) {
revert NoPassOwned();
}
(bool success, ) = prepayBeneficiary.call{value: msg.value}("");
if (!success) {
revert PaymentFailed();
}
emit PrepayCreated(prepayUser, prepayAmount, address(passContract), passTokenId, prepayPrice, block.timestamp);
}
function userMintComplete(uint256 timestamp) external onlyOwner {
emit MintDone(timestamp);
}
receive() external payable {
revert NoErroneousPayments();
}
fallback() external payable {
revert NoErroneousPayments();
}
function getInfo(address user) external view returns (
uint256 balance,
bool hasPass,
address _prepayBeneficiary,
uint256 _prepayPrice,
uint256 _prepayMinMints,
address _owner
) {
balance = user.balance;
hasPass = passContract.balanceOf(user, passTokenId) > 0;
_prepayBeneficiary = prepayBeneficiary;
_prepayPrice = prepayPrice;
_prepayMinMints = prepayMinMints;
_owner = owner();
}
function setPrepayBeneficiary(address payable _prepayBeneficiary) public onlyOwner {
prepayBeneficiary = _prepayBeneficiary;
}
function setPrepayPrice(uint256 _prepayPrice) public onlyOwner {
prepayPrice = _prepayPrice;
emit PrepayPriceChanged(prepayPrice, _prepayPrice, block.timestamp);
}
function setPrepayMinMints(uint256 _prepayMinMints) public onlyOwner {
prepayMinMints = _prepayMinMints;
}
function setPassContract(address _passContract) public onlyOwner {
passContract = IERC1155(_passContract);
}
function setPassTokenId(uint256 _passTokenId) public onlyOwner {
passTokenId = _passTokenId;
}
}
文件 2 的 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;
}
}
文件 3 的 5:IERC1155.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155 is IERC165 {
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
function balanceOf(address account, uint256 id) external view returns (uint256);
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
function setApprovalForAll(address operator, bool approved) external;
function isApprovedForAll(address account, address operator) external view returns (bool);
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 4 的 5:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view 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());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
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": {
"src/ClickCreatePrepay.sol": "ClickCreatePrepay"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[{"internalType":"address","name":"_prepayBeneficiary","type":"address"},{"internalType":"uint256","name":"_prepayPrice","type":"uint256"},{"internalType":"address","name":"_passContract","type":"address"},{"internalType":"uint256","name":"_passTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"IncorrectPrePayAmount","type":"error"},{"inputs":[],"name":"NoErroneousPayments","type":"error"},{"inputs":[],"name":"NoPassOwned","type":"error"},{"inputs":[],"name":"PaymentFailed","type":"error"},{"inputs":[],"name":"TooFewMints","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MintDone","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":"prepayUser","type":"address"},{"indexed":true,"internalType":"uint256","name":"prepayAmount","type":"uint256"},{"indexed":true,"internalType":"address","name":"passContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"passTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"prepayPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PrepayCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldPrepayPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPrepayPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"PrepayPriceChanged","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"address","name":"prepayUser","type":"address"},{"internalType":"uint256","name":"prepayAmount","type":"uint256"}],"name":"createPrepay","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getInfo","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"bool","name":"hasPass","type":"bool"},{"internalType":"address","name":"_prepayBeneficiary","type":"address"},{"internalType":"uint256","name":"_prepayPrice","type":"uint256"},{"internalType":"uint256","name":"_prepayMinMints","type":"uint256"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"passContract","outputs":[{"internalType":"contract IERC1155","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"passTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prepayBeneficiary","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prepayMinMints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prepayPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_passContract","type":"address"}],"name":"setPassContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_passTokenId","type":"uint256"}],"name":"setPassTokenId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_prepayBeneficiary","type":"address"}],"name":"setPrepayBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prepayMinMints","type":"uint256"}],"name":"setPrepayMinMints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_prepayPrice","type":"uint256"}],"name":"setPrepayPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"userMintComplete","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]