编译器
0.8.25+commit.b61c2a91
文件 1 的 14:Arrays.sol
pragma solidity ^0.8.20;
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
library Arrays {
using StorageSlot for bytes32;
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getAddressSlot();
}
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getBytes32Slot();
}
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
assembly {
mstore(0, arr.slot)
slot := add(keccak256(0, 0x20), pos)
}
return slot.getUint256Slot();
}
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
}
文件 2 的 14:Context.sol
pragma solidity ^0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
文件 3 的 14:ERC1155.sol
pragma solidity ^0.8.20;
import {IERC1155} from "./IERC1155.sol";
import {IERC1155Receiver} from "./IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol";
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
using Arrays for uint256[];
using Arrays for address[];
mapping(uint256 id => mapping(address account => uint256)) private _balances;
mapping(address account => mapping(address operator => bool)) private _operatorApprovals;
string private _uri;
constructor(string memory uri_) {
_setURI(uri_);
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
function uri(uint256 ) public view virtual returns (string memory) {
return _uri;
}
function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
return _balances[id][account];
}
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual returns (uint256[] memory) {
if (accounts.length != ids.length) {
revert ERC1155InvalidArrayLength(ids.length, accounts.length);
}
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i));
}
return batchBalances;
}
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address account, address operator) public view virtual returns (bool) {
return _operatorApprovals[account][operator];
}
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeTransferFrom(from, to, id, value, data);
}
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeBatchTransferFrom(from, to, ids, values, data);
}
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual {
_update(from, to, ids, values);
if (to != address(0)) {
address operator = _msgSender();
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
_doSafeTransferAcceptanceCheck(operator, from, to, id, value, data);
} else {
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data);
}
}
}
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
function _burn(address from, uint256 id, uint256 value) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC1155InvalidOperator(address(0));
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) private {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC1155InvalidReceiver(to);
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) private {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC1155InvalidReceiver(to);
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
function _asSingletonArrays(
uint256 element1,
uint256 element2
) private pure returns (uint256[] memory array1, uint256[] memory array2) {
assembly {
array1 := mload(0x40)
mstore(array1, 1)
mstore(add(array1, 0x20), element1)
array2 := add(array1, 0x40)
mstore(array2, 1)
mstore(add(array2, 0x20), element2)
mstore(0x40, add(array2, 0x40))
}
}
}
文件 4 的 14:ERC165.sol
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 5 的 14:IERC1155.sol
pragma solidity ^0.8.20;
import {IERC165} from "../../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 value, bytes calldata data) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}
文件 6 的 14:IERC1155MetadataURI.sol
pragma solidity ^0.8.20;
import {IERC1155} from "../IERC1155.sol";
interface IERC1155MetadataURI is IERC1155 {
function uri(uint256 id) external view returns (string memory);
}
文件 7 的 14:IERC1155Receiver.sol
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
interface IERC1155Receiver is IERC165 {
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
文件 8 的 14:IERC165.sol
pragma solidity ^0.8.20;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 9 的 14:IERC20.sol
pragma solidity ^0.8.20;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
文件 10 的 14:Math.sol
pragma solidity ^0.8.20;
library Math {
error MathOverflowedMulDiv();
enum Rounding {
Floor,
Ceil,
Trunc,
Expand
}
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
return a / b;
}
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0 = x * y;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (0 - denominator);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
文件 11 的 14:Ownable.sol
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 12 的 14:StorageSlot.sol
pragma solidity ^0.8.20;
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly {
r.slot := slot
}
}
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly {
r.slot := store.slot
}
}
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly {
r.slot := slot
}
}
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly {
r.slot := store.slot
}
}
}
文件 13 的 14:buymea.sol
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract BuyMeA is ERC1155, Ownable , IERC1155Receiver{
uint8 private constant PERCENTAGE_PROVISION = 10;
uint8 private constant CNT_ITEMS=3;
uint8 private constant CNT_WINNER=5;
uint256 private gameCost=2500000000000000;
bytes32 private DOMAIN_SEPARATOR;
uint256 private constant SALT = 1122;
error GameEnded(uint256 currentTs, uint256 endTs);
error GameNotEnded(uint256 currentTs,uint256 endTs);
error GameNotStarted(uint256 currentTs,uint256 startTs);
error NoItems();
error NoJackpot();
error NotWinnerFid(uint64 winnerFid, uint64 userFid);
error SignedTransactionExpired(uint256 deadline);
error NotAllowed();
error GameCostNotEnough(uint256 cost);
struct WinnerItem{
uint256 tokenId;
uint64 fid;
uint64 secs;
}
struct Item{
uint256 tokenId;
uint256 currTs;
uint256 cost;
uint64 currFid;
uint64 supply;
mapping(uint64 fid => uint64) fidSeconds;
}
struct Game {
address erc20;
address owner;
address signer;
uint256 start;
uint256 end;
uint256 mintAmount;
uint256 jackpot;
uint256 amountProvision;
uint256 amountProvisionContractOwner;
uint64 provision;
Item[CNT_ITEMS] items;
WinnerItem [CNT_WINNER] winner;
mapping(uint64 fid => bool) fidJoined;
}
struct EIP712Domain {
string name;
string version;
uint256 chainId;
address verifyingContract;
uint256 salt;
}
uint256 private _gameId;
uint256 private _tokenIds;
mapping(uint256 gameId => Game) private games;
mapping(uint256 tokenId => uint256) private tokenIdToGame;
modifier onlyTokenOwner(uint256 tokenId) {
_checkTokenOwner(tokenId);
_;
}
function _checkTokenOwner(uint256 tokenId) internal view virtual {
if (owner() != _msgSender() && tokenOwner(tokenId) != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function tokenOwner(uint256 tokenId) public view virtual returns (address) {
return games[ tokenIdToGame[tokenId]].owner;
}
event newGameMinted(uint256 _id,uint256 tokenId1,uint256 tokenId2,uint256 tokenId3);
event channelTotalAmounts(uint256 _totalAmount);
function contractURI() public view returns (string memory) {
return uri(0);
}
string public name = "DegenFans Game";
constructor() ERC1155("https://f.hellwach.io/farcaster/tokengatedframes/erc1155/token/tt-barton-game/{id}/") Ownable(msg.sender){
DOMAIN_SEPARATOR = hashDomain(EIP712Domain({
name: "BuyMeA",
version: "1",
chainId: block.chainid,
verifyingContract: address(this),
salt: SALT
}));
}
function hashDomain(EIP712Domain memory domain) private pure returns (bytes32) {
return keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,uint256 salt)"),
keccak256(bytes(domain.name)),
keccak256(bytes(domain.version)),
domain.chainId,
domain.verifyingContract,
domain.salt
));
}
function _newGame(address owner,address signer,address erc20, uint64 provision,uint256 end,uint256 start,uint256 cost1,uint256 cost2,uint256 cost3, uint256 mintAmount) internal returns (uint256){
_gameId++;
uint256 newGameId = _gameId;
Game storage game = games[_gameId];
game.owner =owner;
game.erc20= erc20;
game.provision= provision;
game.end = end;
game.start=start;
game.signer=signer;
game.mintAmount=mintAmount;
game.jackpot=0;
game.amountProvision=0;
for(uint256 i;i<CNT_ITEMS;i++){
++_tokenIds;
game.items[i].tokenId=_tokenIds;
if(i==0){
game.items[i].cost=cost1;
}else if(i==1){
game.items[i].cost=cost2;
}else if(i==2){
game.items[i].cost=cost3;
}
tokenIdToGame[_tokenIds]=newGameId;
if(mintAmount>0){
_mint(address(this) , _tokenIds, mintAmount,"0x");
}
}
emit newGameMinted(newGameId,game.items[0].tokenId,game.items[1].tokenId,game.items[2].tokenId);
return newGameId;
}
function changeGameCost(uint256 newCost) external onlyOwner(){
gameCost=newCost;
}
function newGameOwner(address owner,address signer,address erc20,uint64 provision,uint256 end,uint256 start, uint256 cost1, uint256 cost2, uint256 cost3, uint256 mintAmount) external onlyOwner returns (uint256) {
return _newGame(owner,signer,erc20,provision,end,start,cost1,cost2,cost3,mintAmount);
}
function newGame(address owner,address signer,address erc20, uint64 provision,uint256 end,uint256 start,uint256 cost1, uint256 cost2, uint256 cost3, uint256 mintAmount) external payable returns (uint256) {
if(msg.value < gameCost){
revert GameCostNotEnough({cost:gameCost});
}
return _newGame(owner,signer,erc20,provision,end,start,cost1,cost2,cost3,mintAmount);
}
function grabItem(address erc20Sender, uint256 gameId,uint8 itemNr,uint256 amount,uint64 fid, bytes memory data) external {
Game storage game=games[gameId];
if(game.start >= block.timestamp){
revert GameNotStarted({currentTs:block.timestamp,startTs:game.start});
}
if(game.end <= block.timestamp){
revert GameEnded({currentTs:block.timestamp,endTs:game.end});
}
Item storage item = game.items[itemNr-1];
if(game.mintAmount>0 && balanceOf(address(this),item.tokenId)==0){
revert NoItems();
}
uint256 totalCost=item.cost*amount;
IERC20(game.erc20 ).transferFrom(erc20Sender, address(this) , totalCost );
uint256 ownerProvision=totalCost*PERCENTAGE_PROVISION/100;
game.amountProvisionContractOwner +=ownerProvision;
uint256 gameProvision=(totalCost-ownerProvision )*game.provision/100;
game.amountProvision +=gameProvision;
game.jackpot += (totalCost-ownerProvision ) - gameProvision;
if(item.currFid > 0){
item.fidSeconds[item.currFid]=uint64(item.fidSeconds[item.currFid]+(block.timestamp-item.currTs));
fillWinnerArray(game,item,item.fidSeconds[item.currFid]);
}
item.currFid=fid;
item.currTs=block.timestamp;
item.supply=item.supply+1;
if(!game.fidJoined[fid]){
game.fidJoined[fid]=true;
}
if(game.mintAmount == 0){
_mint(msg.sender , item.tokenId, amount,data);
}else {
_safeTransferFrom(address(this) ,msg.sender, item.tokenId, amount, data);
}
}
function hasJoined(uint256 gameId,uint64 fid) public view returns(bool){
return games[gameId].fidJoined[fid];
}
function fillWinnerArray(Game storage game,Item storage item, uint64 secs) internal{
uint256 newPlace=0;
uint256 oldPlace=0;
bool foundNewPlace;
bool foundOldPlace;
bool foundOldSameValue;
for(uint256 i;i<CNT_WINNER;i++){
if(!foundNewPlace && secs> game.winner[i].secs){
newPlace=i;
foundNewPlace=true;
}
if(!foundOldPlace && item.tokenId == game.winner[i].tokenId && item.currFid== game.winner[i].fid ){
oldPlace=i;
foundOldPlace=true;
if(secs == game.winner[i].secs){
foundOldSameValue=true;
}
}
if(foundNewPlace && foundOldPlace){
break;
}
}
if(foundOldSameValue){
return;
}
if (foundOldPlace && foundNewPlace) {
for (uint256 i = oldPlace + 1; i < CNT_WINNER; i++) {
game.winner[i - 1] = game.winner[i];
}
}
if (foundNewPlace) {
uint256 i = CNT_WINNER - 2;
while(i >= newPlace){
game.winner[i + 1] = game.winner[i];
if(i==0){
break;
}
i--;
}
game.winner[newPlace].tokenId=item.tokenId;
game.winner[newPlace].fid=item.currFid;
game.winner[newPlace].secs=secs;
}
}
function claimWin(uint256 gameId,address claimAddress,uint64 fid,uint256 deadline, uint8 v, bytes32 r, bytes32 s) external{
Game storage game=games[gameId];
if(game.end > block.timestamp){
revert GameNotEnded({currentTs:block.timestamp,endTs:game.end});
}
if(game.jackpot==0){
revert NoJackpot();
}
WinnerItem memory wi= getWinner(gameId)[0];
if(fid!=wi.fid){
revert NotWinnerFid({winnerFid:wi.fid,userFid:fid});
}
if(!checkFid(gameId,game.signer,claimAddress,fid,deadline,v,r,s)){
revert NotAllowed();
}
IERC20(game.erc20 ).transfer( claimAddress, game.jackpot );
game.jackpot =0;
}
function getWinnerAsIs(uint256 gameId) public view returns (WinnerItem [5] memory retwinner){
Game storage game=games[gameId];
WinnerItem[CNT_WINNER] memory winner;
for(uint256 i;i<CNT_WINNER;i++){
winner[i].fid=game.winner[i].fid;
winner[i].tokenId=game.winner[i].tokenId;
winner[i].secs=game.winner[i].secs;
}
return winner;
}
function isWinner(uint256 gameId,uint64 fid) public view returns (bool){
return getWinner(gameId)[0].fid==fid;
}
function getWinnerFid(uint256 gameId ) public view returns (uint64){
return getWinner(gameId)[0].fid;
}
function getWinner(uint256 gameId) public view returns (WinnerItem [5] memory retwinner){
uint256 ts= block.timestamp;
Game storage game=games[gameId];
if(game.end<=ts){
ts=game.end;
}
WinnerItem[CNT_WINNER] memory winner;
for(uint256 i;i<CNT_WINNER;i++){
winner[i].fid=game.winner[i].fid;
winner[i].tokenId=game.winner[i].tokenId;
winner[i].secs=game.winner[i].secs;
}
for(uint256 i;i<CNT_ITEMS;i++){
if(game.items[i].currFid!=0){
uint64 secs=uint64(game.items[i].fidSeconds[game.items[i].currFid]+(ts-game.items[i].currTs));
winner=fillWinnerArrayTemp(winner,game.items[i].tokenId,game.items[i].currFid,secs);
}
}
return winner;
}
function getBlockTs()public view returns(uint256){
return block.timestamp;
}
function getItems(uint256 gameId ) public view returns (uint256 [3] memory tokenIds,uint64 [3] memory fids,uint256 [3]memory ts){
Game storage game=games[gameId];
for(uint256 i;i<CNT_ITEMS;i++){
tokenIds[i]=game.items[i].tokenId;
fids[i]=game.items[i].currFid;
ts[i]=game.items[i].currTs;
}
return (tokenIds,fids,ts);
}
function fillWinnerArrayTemp( WinnerItem[5] memory winner,uint256 tokenId,uint64 fid, uint64 secs) internal pure returns (WinnerItem [5] memory){
uint256 newPlace=0;
uint256 oldPlace=0;
bool foundNewPlace;
bool foundOldPlace;
bool foundOldSameValue;
for(uint256 i;i< CNT_WINNER;i++){
if(!foundNewPlace && secs> winner[i].secs){
newPlace=i;
foundNewPlace=true;
}
if(!foundOldPlace && tokenId == winner[i].tokenId && fid== winner[i].fid ){
oldPlace=i;
foundOldPlace=true;
if(secs == winner[i].secs){
foundOldSameValue=true;
}
}
if(foundNewPlace && foundOldPlace){
break;
}
}
if(foundOldSameValue){
return winner;
}
if (foundOldPlace && foundNewPlace) {
for (uint256 i = oldPlace + 1; i < CNT_WINNER; i++) {
winner[i - 1] = winner[i];
}
}
if (foundNewPlace) {
uint256 i = CNT_WINNER - 2;
while(i >= newPlace){
winner[i + 1] = winner[i];
if(i==0){
break;
}
i--;
}
WinnerItem memory w;
winner[newPlace]= w;
w.fid=fid;
w.tokenId=tokenId;
w.secs=secs;
}
return winner;
}
function claimProvision(uint256 gameId) external{
Game storage game=games[gameId];
require(game.owner==msg.sender,"not owner");
require(game.amountProvision >0,"no provision");
IERC20(game.erc20 ).transferFrom(address(this), msg.sender, game.amountProvision );
game.amountProvision=0;
}
function claimProvisionOwner(uint256 gameId)external onlyOwner{
Game storage game=games[gameId];
require(game.amountProvisionContractOwner >0,"no provision");
IERC20(game.erc20 ).transferFrom(address(this), msg.sender, game.amountProvisionContractOwner );
game.amountProvisionContractOwner=0;
}
function checkFid(uint256 gameId,address gameSigner,address claimAddress,uint64 fid,uint256 deadline,uint8 v, bytes32 r, bytes32 s) internal view returns (bool){
if(block.timestamp>=deadline){
revert SignedTransactionExpired({deadline:deadline});
}
bytes32 hashStruct = keccak256(
abi.encode(
keccak256("claimWin(uint256 gameId,address claimAddress,uint64 fid,uint256 deadline)"),
gameId,
claimAddress,
fid,
deadline
)
);
bytes32 hash = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, hashStruct));
address signer = ecrecover(hash, v, r, s);
require(signer == gameSigner, "MyFunction: invalid signature");
require(signer != address(0), "ECDSA: invalid signature");
return signer == gameSigner;
}
function getGame(uint256 gameId)public view returns(uint256 ,uint256 ,uint256 ,uint256[CNT_ITEMS] memory,uint256[CNT_ITEMS] memory,uint64[CNT_WINNER] memory,uint256[CNT_WINNER] memory,uint64[CNT_WINNER] memory){
uint256[CNT_ITEMS] memory rettokenId;
uint256[CNT_ITEMS] memory retbalance;
Game storage game=games[gameId];
for(uint256 i;i<CNT_ITEMS;i++){
rettokenId[i]=game.items[i].tokenId;
retbalance[i]= game.items[i].supply;
}
WinnerItem[CNT_WINNER] memory winner=getWinner(gameId);
uint64[CNT_WINNER] memory retFids;
uint256[CNT_WINNER] memory retFidTokenId;
uint64[CNT_WINNER] memory retSecs;
for(uint256 i;i<CNT_WINNER;i++){
retFids[i]=winner[i].fid;
retFidTokenId[i]=winner[i].tokenId;
retSecs[i]=winner[i].secs;
}
return (game.end,game.start,game.jackpot,rettokenId,retbalance,retFids,retFidTokenId,retSecs );
}
function getGameJackpot(uint256 gameId) public view returns(uint) {
return games[gameId].jackpot;
}
function getGameProvision(uint256 gameId) public view returns(uint) {
return games[gameId].amountProvision;
}
function getGameProvisionOwner(uint256 gameId) public view returns(uint) {
return games[gameId].amountProvisionContractOwner;
}
function getEthBalance() public view returns(uint) {
return address(this).balance;
}
function getOwner(uint256 gameId) public view returns(address) {
return games[gameId].owner;
}
function getCost(uint256 gameId,uint256 itemNr) public view returns(uint256) {
return games[gameId].items[itemNr-1].cost;
}
function getErc20(uint256 gameId) public view returns(address) {
return games[gameId].erc20;
}
function withdrawMoney() public onlyOwner{
address payable to = payable(msg.sender);
to.transfer(getEthBalance());
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
文件 14 的 14:draft-IERC6093.sol
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"contracts/buymea.sol": "BuyMeA"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": [],
"viaIR": true
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[{"internalType":"uint256","name":"cost","type":"uint256"}],"name":"GameCostNotEnough","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentTs","type":"uint256"},{"internalType":"uint256","name":"endTs","type":"uint256"}],"name":"GameEnded","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentTs","type":"uint256"},{"internalType":"uint256","name":"endTs","type":"uint256"}],"name":"GameNotEnded","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentTs","type":"uint256"},{"internalType":"uint256","name":"startTs","type":"uint256"}],"name":"GameNotStarted","type":"error"},{"inputs":[],"name":"NoItems","type":"error"},{"inputs":[],"name":"NoJackpot","type":"error"},{"inputs":[],"name":"NotAllowed","type":"error"},{"inputs":[{"internalType":"uint64","name":"winnerFid","type":"uint64"},{"internalType":"uint64","name":"userFid","type":"uint64"}],"name":"NotWinnerFid","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"SignedTransactionExpired","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","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":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_totalAmount","type":"uint256"}],"name":"channelTotalAmounts","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId3","type":"uint256"}],"name":"newGameMinted","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newCost","type":"uint256"}],"name":"changeGameCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"claimProvision","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"claimProvisionOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"address","name":"claimAddress","type":"address"},{"internalType":"uint64","name":"fid","type":"uint64"},{"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":"claimWin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockTs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"itemNr","type":"uint256"}],"name":"getCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getErc20","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGame","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256[3]","name":"","type":"uint256[3]"},{"internalType":"uint256[3]","name":"","type":"uint256[3]"},{"internalType":"uint64[5]","name":"","type":"uint64[5]"},{"internalType":"uint256[5]","name":"","type":"uint256[5]"},{"internalType":"uint64[5]","name":"","type":"uint64[5]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameJackpot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameProvision","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameProvisionOwner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getItems","outputs":[{"internalType":"uint256[3]","name":"tokenIds","type":"uint256[3]"},{"internalType":"uint64[3]","name":"fids","type":"uint64[3]"},{"internalType":"uint256[3]","name":"ts","type":"uint256[3]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getWinner","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"fid","type":"uint64"},{"internalType":"uint64","name":"secs","type":"uint64"}],"internalType":"struct BuyMeA.WinnerItem[5]","name":"retwinner","type":"tuple[5]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getWinnerAsIs","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint64","name":"fid","type":"uint64"},{"internalType":"uint64","name":"secs","type":"uint64"}],"internalType":"struct BuyMeA.WinnerItem[5]","name":"retwinner","type":"tuple[5]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getWinnerFid","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc20Sender","type":"address"},{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint8","name":"itemNr","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"fid","type":"uint64"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"grabItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint64","name":"fid","type":"uint64"}],"name":"hasJoined","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint64","name":"fid","type":"uint64"}],"name":"isWinner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"erc20","type":"address"},{"internalType":"uint64","name":"provision","type":"uint64"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"cost1","type":"uint256"},{"internalType":"uint256","name":"cost2","type":"uint256"},{"internalType":"uint256","name":"cost3","type":"uint256"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"newGame","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"erc20","type":"address"},{"internalType":"uint64","name":"provision","type":"uint64"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"cost1","type":"uint256"},{"internalType":"uint256","name":"cost2","type":"uint256"},{"internalType":"uint256","name":"cost3","type":"uint256"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"newGameOwner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"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":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawMoney","outputs":[],"stateMutability":"nonpayable","type":"function"}]