Contract Overview
Balance:
0 AVAX
AVAX Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x125a06cf1df67011b5654fcfc6c74e3d251d22afcc3df5fe8fc3db169f669843 | Create Edition | 27644112 | 11 days 9 hrs ago | 0x3a833739f8596ec65639cdecbfb4215e5f6dce48 | IN | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | 0 AVAX | 0.019474675 | |
0x1624e14aad9b829cf60b13e7504a9b745b4dd608e61a6db22ca5b70042c44efa | Create Edition | 27571524 | 13 days 1 hr ago | 0x8406a51a0e1b5f52ff61226773e6328e5da5d964 | IN | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | 0 AVAX | 0.047808292593 | |
0x0e7815c6f5102e40cfc1ed1407349f06bd99289d0605550318e1755c370a8168 | Create Edition | 27563990 | 13 days 6 hrs ago | 0x8406a51a0e1b5f52ff61226773e6328e5da5d964 | IN | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | 0 AVAX | 0.04946593488 | |
0x4633ea8edb2018b41648d35ad04f096867677537957ed5035a63863febab60f2 | 0x60c06040 | 27484095 | 15 days 3 hrs ago | 0x8406a51a0e1b5f52ff61226773e6328e5da5d964 | IN | Create: BunyRaffleFactory | 0 AVAX | 0.029249 |
[ Download CSV Export ]
Latest 3 internal transactions
Parent Txn Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
0x125a06cf1df67011b5654fcfc6c74e3d251d22afcc3df5fe8fc3db169f669843 | 27644112 | 11 days 9 hrs ago | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | Contract Creation | 0 AVAX | ||
0x1624e14aad9b829cf60b13e7504a9b745b4dd608e61a6db22ca5b70042c44efa | 27571524 | 13 days 1 hr ago | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | Contract Creation | 0 AVAX | ||
0x0e7815c6f5102e40cfc1ed1407349f06bd99289d0605550318e1755c370a8168 | 27563990 | 13 days 6 hrs ago | 0x7a9e8c1ac540ee5b0e94a85d6d1619226d8c57fe | Contract Creation | 0 AVAX |
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
BunyRaffleFactory
Compiler Version
v0.8.16+commit.07a7930e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../token/ERC721/extensions/IERC721EnumerableUpgradeable.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library ClonesUpgradeable { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal onlyInitializing { } function __ERC721Enumerable_init_unchained() internal onlyInitializing { } // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721Upgradeable.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[46] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides functions for encoding/decoding base64 library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and( input, 0x3F)))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and( input , 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } }
///bunyRaffle // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.11; import {ClonesUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "./BunyRaffleNft.sol"; contract BunyRaffleFactory is OwnableUpgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private atContract; address public implementation; string _name = "Buny Raffle 2023"; string _symbol = "rBUNY"; //string _animationUrl = "https://ipfs.io/ipfs/Qmd94YsrsK5jPbi675XiwyLwMhcM6HS6MULC7mqQGMnXtW"; uint256 _prime = 432211379112113246928842014508850435796007; address payable public _bunyBank; uint256 _iterations = 1337; uint256 public collectionCount = 0; event CreatedEdition(uint256 indexed editionId, address indexed creator, uint256 editionSize, address indexed editionContractAddress, uint256 minPlayers, uint256 maxTokens, uint256 salePrice); Collection[] public collection; struct Collection { string _name; address editionContractAddress; uint256 _editionSize; uint256 newId; uint256 _minPlayers; uint256 _maxTokens; uint256 _salePrice; string _imageUrl; } /// Initializes factory with address of implementation logic constructor(address _implementation, address payable bunyBank) { implementation = _implementation; _bunyBank = bunyBank; } function owner() public view override(OwnableUpgradeable) returns (address) { return super.owner(); } function createEdition( string memory _description, string memory _imageUrl, uint256 _editionSize, uint256 _salePrice, uint256 _minPlayers, uint256 _maxTokens ) external returns (uint256) { uint256 newId = atContract.current(); address newContract = ClonesUpgradeable.cloneDeterministic( implementation, bytes32(abi.encodePacked(newId)) ); BunyRaffleNft(newContract).initialize( msg.sender, _name, _symbol, _description, _imageUrl, _editionSize, _salePrice, _minPlayers, _bunyBank, _maxTokens, _prime, _iterations ); emit CreatedEdition(newId, msg.sender, _editionSize, newContract, _minPlayers, _maxTokens, _salePrice ); atContract.increment(); Collection memory x = Collection(_name, newContract, _editionSize, newId, _minPlayers, _maxTokens, _salePrice, _imageUrl); collection.push(x); collectionCount ++; return newId; } function setBunyBankAddress(address payable bunyBank) external onlyOwner { require(bunyBank != address(0), "Invalid BB address"); _bunyBank = bunyBank; } function readAllCollections() public view returns (Collection[] memory) { Collection[] memory result = new Collection[](collectionCount); for (uint256 i = 0; i < collectionCount; i++) { result[i] = collection[i]; } return result; } function getRaffleAtId(uint256 raffleId) external view returns (BunyRaffleNft) { return BunyRaffleNft( ClonesUpgradeable.predictDeterministicAddress( implementation, bytes32(abi.encodePacked(raffleId)), address(this) ) ); } }
//bunyNFt // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.11; import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {ERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import { IERC721EnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC721EnumerableUpgradeable.sol"; import { IERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { CountersUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import { AddressUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import { SharedNFTLogic } from "./SharedNFTLogic.sol"; import { IEditionSingleMintable } from "./IEditionSingleMintable.sol"; import "./SlothVDF.sol"; contract BunyRaffleNft is ERC721Upgradeable, IEditionSingleMintable, OwnableUpgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; SharedNFTLogic private immutable sharedNFTLogic; CountersUpgradeable.Counter private atEditionId; event Rafflestarted(address minter, uint256 startTime); event Editionsold(uint256 price, address owner, uint256 EntryCount, uint256 entryTime); event WinnerPicked(address winner, uint256 winningNumber, uint256 prize); string public description; string public animationUrl; string public imageUrl; uint256 public editionSize; uint256 public salePrice; uint256 public minPlayers; uint256 public maxTokens; bool public active = false; bool public winnerSelected = false; bool public isComplete = false; bool public isProof = false; bool public prizeClaimed = false; uint256 public startTime; uint256 public endTime; uint256 public EntryCount = 0; uint256 public prime = 0; uint256 public iterations = 0; uint256 private nonce = 0; uint256 public randomNumber = 0; uint256 public winningNumber = 0; address payable public Winner; address payable public bunyBank; Entry[] private entry; RaffleWinner[] public raffleWinner; uint256[] public nftTokenIds; mapping(address => bool) public mintedTokens; mapping(address => bool) public allowedMinters; mapping(address => uint256) public seed; mapping(address => bool) public isPlayer; struct Entry { address player; uint256 EntryNumber; uint256 entryTime; } struct RaffleWinner { address payable winner; uint256 winningTokenId; } constructor( SharedNFTLogic _sharedNFTLogic) { sharedNFTLogic = _sharedNFTLogic; } function initialize( address _owner, string memory _name, string memory _symbol, string memory _description, //string memory _animationUrl, string memory _imageUrl, uint256 _editionSize, uint256 _salePrice, uint256 _minPlayers, address payable _bunyBank, uint256 _maxTokens, uint256 _prime, uint256 _iterations ) public initializer { __ERC721_init(_name, _symbol); __Ownable_init(); // Set ownership to original sender of contract call transferOwnership(_owner); description = _description; //animationUrl = _animationUrl; imageUrl = _imageUrl; editionSize = _editionSize; salePrice = _salePrice; minPlayers = _minPlayers; bunyBank = _bunyBank; maxTokens = _maxTokens; prime = _prime; iterations = _iterations; atEditionId.increment(); } /// @dev returns the number of minted tokens within the edition function totalSupply() public view returns (uint256) { return atEditionId.current() - 1; } // return balance in wei function getBalance() public view returns(uint){ return address(this).balance; } // return prize balance function getPrize() external view returns (uint256) { uint256 balance = address(this).balance; return balance * 9 / 10; //90% } function purchase() external payable returns (uint256) { require(balanceOf(msg.sender) < maxTokens, "You have reached the maximum tokens allowed per address"); require(active, "Raffle has not started. Owner must setApprovedMinter"); require(msg.value == salePrice, "No soup for you!"); address[] memory toMint = new address[](1); toMint[0] = msg.sender; mintedTokens[msg.sender] = true; nonce ++; createSeed(); EntryCount ++; isPlayer[msg.sender] = true; nftTokenIds.push(EntryCount); uint256 entryTime = block.timestamp; Entry memory x = Entry(msg.sender, EntryCount, entryTime); entry.push(x); if (EntryCount == editionSize) { isComplete = true; active = false; } emit Editionsold(salePrice, msg.sender, EntryCount, entryTime); return _mintEditions(toMint); } function createSeed() internal returns(uint256) { nonce ++; seed[msg.sender] = uint256(keccak256(abi.encodePacked(msg.sender, EntryCount, block.timestamp, blockhash(block.number - 1)))); } function prove(uint256 proof) external { nonce ++; // see if the proof is valid for the seed associated with the address require(SlothVDF.verify(proof, seed[msg.sender], prime, iterations), "Invalid proof"); // use the proof as a provable random number randomNumber = proof; if (randomNumber > 0) { isProof = true; } } function getOwner(uint _id) public view returns (address) { return ownerOf(_id); } function pickWinner() public returns (uint256) { require(randomNumber > 0, "Generate provable random number first"); require(isPlayer[msg.sender], "User is not a active player. Only a registered ticket holder can start drawing"); nonce ++; winningNumber = uint256(keccak256(abi.encodePacked(block.number, randomNumber, blockhash(block.number - 1)))) % totalSupply(); address winner = getOwner(winningNumber); uint256 prize = address(this).balance * 90 / 100; Winner = payable(winner); emit WinnerPicked(Winner, winningNumber, prize); winnerSelected = true; active = false; RaffleWinner memory x = RaffleWinner(Winner, winningNumber); raffleWinner.push(x); Winner.transfer(prize); withdrawBuny(); endTime = block.timestamp; return winningNumber; } //failsafe? function claimPrize(uint256 _winningNumber) public { address payable tokenOwner = payable(ownerOf(_winningNumber)); require(msg.sender == tokenOwner, "Only the owner of this token can withdraw the balance"); require(winnerSelected, "The contract has no balance to withdraw"); uint256 balance = address(this).balance * 90/100; (bool success, ) = tokenOwner.call{value: balance}(""); prizeClaimed = true; withdrawBuny(); require(success, "Withdrawal failed"); } function _isAllowedToMint() internal view returns (bool) { if (owner() == msg.sender) { return true; } if (allowedMinters[address(0x0)]) { return true; } return allowedMinters[msg.sender]; } function mintEdition(address to) external override returns (uint256) { require(_isAllowedToMint(), "Needs to be an allowed minter"); address[] memory toMint = new address[](1); toMint[0] = to; return _mintEditions(toMint); } function mintEditions(address[] memory recipients) external override returns (uint256) { require(_isAllowedToMint(), "Needs to be an allowed minter"); return _mintEditions(recipients); } function owner() public view override(OwnableUpgradeable, IEditionSingleMintable) returns (address) { return super.owner(); } // helper function starts raffle once setApprovedMinter. function enableRaffle() public onlyOwner { active = true; } function readAllEntries() public view returns (Entry[] memory) { Entry[] memory result = new Entry[](EntryCount); for (uint256 i = 0; i < EntryCount; i++) { result[i] = entry[i]; } return result; } // set contract address as Approved minter // set active state to false // log and emit current time function setApprovedMinter(address minter, bool allowed) public onlyOwner { allowedMinters[minter] = allowed; enableRaffle(); startTime = block.timestamp; emit Rafflestarted(minter, startTime); } /// Returns the number of editions allowed to mint (max_uint256 when open edition) function numberCanMint() public view override returns (uint256) { // Return max int if open edition if (editionSize == 0) { return type(uint256).max; } // atEditionId is one-indexed hence the need to remove one here return editionSize + 1 - atEditionId.current(); } /** @dev Private function to mint als without any access checks. Called by the public edition minting functions. */ function _mintEditions(address[] memory recipients) internal returns (uint256) { uint256 startAt = atEditionId.current(); uint256 endAt = startAt + recipients.length - 1; require(editionSize == 0 || endAt <= editionSize, "Sold out"); while (atEditionId.current() <= endAt) { _mint(recipients[atEditionId.current() - startAt], atEditionId.current()); atEditionId.increment(); } return atEditionId.current(); } function withdrawBuny() internal { uint256 amount = address(this).balance * 10 / 100; require(isComplete, "Raffle sale must be complete before withdraw function is enabled"); require(amount > 0, "Contract A has no balance to withdraw"); bunyBank.transfer(amount); } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "No token"); return sharedNFTLogic.createMetadataEdition(name(), description, imageUrl, animationUrl, tokenId, editionSize); } function supportsInterface( bytes4 interfaceId ) public view virtual override( ERC721Upgradeable) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; interface IEditionSingleMintable { function mintEdition(address to) external returns (uint256); function mintEditions(address[] memory to) external returns (uint256); function numberCanMint() external view returns (uint256); function owner() external view returns (address); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6; /// Shared public library for on-chain NFT functions interface IPublicSharedMetadata { /// @param unencoded bytes to base64-encode function base64Encode(bytes memory unencoded) external pure returns (string memory); /// Encodes the argument json bytes into base64-data uri format /// @param json Raw json to base64 and turn into a data-uri function encodeMetadataJSON(bytes memory json) external pure returns (string memory); /// Proxy to openzeppelin's toString function /// @param value number to return as a string function numberToString(uint256 value) external pure returns (string memory); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.7; import { StringsUpgradeable } from '@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol'; import { Base64 } from 'base64-sol/base64.sol'; import { IPublicSharedMetadata } from './IPublicSharedMetadata.sol'; /// Shared NFT logic for rendering metadata associated with editions /// @dev Can safely be used for generic base64Encode and numberToString functions contract SharedNFTLogic is IPublicSharedMetadata { /// @param unencoded bytes to base64-encode function base64Encode(bytes memory unencoded) public pure override returns (string memory) { return Base64.encode(unencoded); } /// Proxy to openzeppelin's toString function /// @param value number to return as a string function numberToString(uint256 value) public pure override returns (string memory) { return StringsUpgradeable.toString(value); } /// Generate edition metadata from storage information as base64-json blob /// Combines the media data and metadata /// @param name Name of NFT in metadata /// @param description Description of NFT in metadata /// @param imageUrl URL of image to render for edition /// @param animationUrl URL of animation to render for edition /// @param tokenOfEdition Token ID for specific token /// @param editionSize Size of entire edition to show function createMetadataEdition( string memory name, string memory description, string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition, uint256 editionSize ) external pure returns (string memory) { string memory _tokenMediaData = tokenMediaData(imageUrl, animationUrl, tokenOfEdition); bytes memory json = createMetadataJSON(name, description, _tokenMediaData, tokenOfEdition, editionSize); return encodeMetadataJSON(json); } /// Function to create the metadata json string for the nft edition /// @param name Name of NFT in metadata /// @param description Description of NFT in metadata /// @param mediaData Data for media to include in json object /// @param tokenOfEdition Token ID for specific token /// @param editionSize Size of entire edition to show function createMetadataJSON( string memory name, string memory description, string memory mediaData, uint256 tokenOfEdition, uint256 editionSize ) public pure returns (bytes memory) { bytes memory editionSizeText; if (editionSize > 0) { editionSizeText = abi.encodePacked('/', numberToString(editionSize)); } return abi.encodePacked( '{"name": "', name, ' ', numberToString(tokenOfEdition), editionSizeText, '", "', 'description": "', description, '", "', mediaData, 'properties": {"number": ', numberToString(tokenOfEdition), ', "name": "', name, '"}}' ); } /// Encodes the argument json bytes into base64-data uri format /// @param json Raw json to base64 and turn into a data-uri function encodeMetadataJSON(bytes memory json) public pure override returns (string memory) { return string(abi.encodePacked('data:application/json;base64,', base64Encode(json))); } /// Generates edition metadata from storage information as base64-json blob /// Combines the media data and metadata /// @param imageUrl URL of image to render for edition /// @param animationUrl URL of animation to render for edition function tokenMediaData(string memory imageUrl, string memory animationUrl, uint256 tokenOfEdition) public pure returns (string memory) { bool hasImage = bytes(imageUrl).length > 0; bool hasAnimation = bytes(animationUrl).length > 0; if (hasImage && hasAnimation) { return string( abi.encodePacked( 'image": "', imageUrl, '?id=', numberToString(tokenOfEdition), '", "animation_url": "', animationUrl, '?id=', numberToString(tokenOfEdition), '", "' ) ); } if (hasImage) { return string(abi.encodePacked('image": "', imageUrl, '?id=', numberToString(tokenOfEdition), '", "')); } if (hasAnimation) { return string(abi.encodePacked('animation_url": "', animationUrl, '?id=', numberToString(tokenOfEdition), '", "')); } return ''; } }
// SPDX-License-Identifier: MIT // https://eprint.iacr.org/2015/366.pdf pragma solidity ^0.8.11; library SlothVDF { /// @dev pow(base, exponent, modulus) /// @param base base /// @param exponent exponent /// @param modulus modulus function bexmod( uint256 base, uint256 exponent, uint256 modulus ) internal pure returns (uint256) { uint256 _result = 1; uint256 _base = base; for (; exponent > 0; exponent >>= 1) { if (exponent & 1 == 1) { _result = mulmod(_result, _base, modulus); } _base = mulmod(_base, _base, modulus); } return _result; } /// @dev compute sloth starting from seed, over prime, for iterations /// @param _seed seed /// @param _prime prime /// @param _iterations number of iterations /// @return sloth result function compute( uint256 _seed, uint256 _prime, uint256 _iterations ) internal pure returns (uint256) { uint256 _exponent = (_prime + 1) >> 2; _seed %= _prime; for (uint256 i; i < _iterations; ++i) { _seed = bexmod(_seed, _exponent, _prime); } return _seed; } /// @dev verify sloth result proof, starting from seed, over prime, for iterations /// @param _proof result /// @param _seed seed /// @param _prime prime /// @param _iterations number of iterations /// @return true if y is a quadratic residue modulo p function verify( uint256 _proof, uint256 _seed, uint256 _prime, uint256 _iterations ) internal pure returns (bool) { for (uint256 i; i < _iterations; ++i) { _proof = mulmod(_proof, _proof, _prime); } _seed %= _prime; if (_seed == _proof) return true; if (_prime - _seed == _proof) return true; return false; } }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[{"internalType":"address","name":"_implementation","type":"address"},{"internalType":"address payable","name":"bunyBank","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"editionId","type":"uint256"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"editionSize","type":"uint256"},{"indexed":true,"internalType":"address","name":"editionContractAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"minPlayers","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"CreatedEdition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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"},{"inputs":[],"name":"_bunyBank","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collection","outputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"editionContractAddress","type":"address"},{"internalType":"uint256","name":"_editionSize","type":"uint256"},{"internalType":"uint256","name":"newId","type":"uint256"},{"internalType":"uint256","name":"_minPlayers","type":"uint256"},{"internalType":"uint256","name":"_maxTokens","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"},{"internalType":"string","name":"_imageUrl","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_description","type":"string"},{"internalType":"string","name":"_imageUrl","type":"string"},{"internalType":"uint256","name":"_editionSize","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"},{"internalType":"uint256","name":"_minPlayers","type":"uint256"},{"internalType":"uint256","name":"_maxTokens","type":"uint256"}],"name":"createEdition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"raffleId","type":"uint256"}],"name":"getRaffleAtId","outputs":[{"internalType":"contract BunyRaffleNft","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"readAllCollections","outputs":[{"components":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"editionContractAddress","type":"address"},{"internalType":"uint256","name":"_editionSize","type":"uint256"},{"internalType":"uint256","name":"newId","type":"uint256"},{"internalType":"uint256","name":"_minPlayers","type":"uint256"},{"internalType":"uint256","name":"_maxTokens","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"},{"internalType":"string","name":"_imageUrl","type":"string"}],"internalType":"struct BunyRaffleFactory.Collection[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"bunyBank","type":"address"}],"name":"setBunyBankAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c0604052601060809081526f42756e7920526166666c65203230323360801b60a05260679062000031908262000186565b506040805180820190915260058152647242554e5960d81b60208201526068906200005d908262000186565b507104f627b3bbd341d240517fe3db99ad3b2c27606955610539606b556000606c553480156200008c57600080fd5b506040516200144638038062001446833981016040819052620000af916200026b565b606680546001600160a01b039384166001600160a01b031991821617909155606a8054929093169116179055620002aa565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200010c57607f821691505b6020821081036200012d57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200018157600081815260208120601f850160051c810160208610156200015c5750805b601f850160051c820191505b818110156200017d5782815560010162000168565b5050505b505050565b81516001600160401b03811115620001a257620001a2620000e1565b620001ba81620001b38454620000f7565b8462000133565b602080601f831160018114620001f25760008415620001d95750858301515b600019600386901b1c1916600185901b1785556200017d565b600085815260208120601f198616915b82811015620002235788860151825594840194600190910190840162000202565b5085821015620002425787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6001600160a01b03811681146200026857600080fd5b50565b600080604083850312156200027f57600080fd5b82516200028c8162000252565b60208401519092506200029f8162000252565b809150509250929050565b61118c80620002ba6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c8063adee9cc411610071578063adee9cc414610116578063d57f966b1461012b578063df18d1fd14610142578063ef5c18bf14610155578063f077237714610168578063f2fde38b1461018f57600080fd5b80630dcd5f2b146100ae5780635c60da1b146100de578063715018a6146100f15780637427fd32146100fb5780638da5cb5b1461010e575b600080fd5b6100c16100bc366004610ba2565b6101a2565b6040516001600160a01b0390911681526020015b60405180910390f35b6066546100c1906001600160a01b031681565b6100f9610241565b005b606a546100c1906001600160a01b031681565b6100c1610255565b61011e61026e565b6040516100d59190610c01565b610134606c5481565b6040519081526020016100d5565b6100f9610150366004610ce5565b6104ef565b610134610163366004610dac565b610569565b61017b610176366004610ba2565b61085d565b6040516100d5989796959493929190610e33565b6100f961019d366004610ce5565b6109d8565b606654604080516020810184905260009261023b926001600160a01b0390911691016040516020818303038152906040526101dc90610e96565b30604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b8152606093841b60148201526f5af43d82803e903d91602b57fd5bf3ff60801b6028820152921b6038830152604c8201526037808220606c830152605591012090565b92915050565b610249610a51565b6102536000610ab0565b565b60006102696033546001600160a01b031690565b905090565b60606000606c5467ffffffffffffffff81111561028d5761028d610d09565b60405190808252806020026020018201604052801561030f57816020015b6102fc6040518061010001604052806060815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001606081525090565b8152602001906001900390816102ab5790505b50905060005b606c548110156104e957606d818154811061033257610332610eba565b90600052602060002090600802016040518061010001604052908160008201805461035c90610ed0565b80601f016020809104026020016040519081016040528092919081815260200182805461038890610ed0565b80156103d55780601f106103aa576101008083540402835291602001916103d5565b820191906000526020600020905b8154815290600101906020018083116103b857829003601f168201915b505050918352505060018201546001600160a01b03166020820152600282015460408201526003820154606082015260048201546080820152600582015460a0820152600682015460c082015260078201805460e09092019161043790610ed0565b80601f016020809104026020016040519081016040528092919081815260200182805461046390610ed0565b80156104b05780601f10610485576101008083540402835291602001916104b0565b820191906000526020600020905b81548152906001019060200180831161049357829003601f168201915b5050505050815250508282815181106104cb576104cb610eba565b602002602001018190525080806104e190610f04565b915050610315565b50919050565b6104f7610a51565b6001600160a01b0381166105475760405162461bcd60e51b8152602060048201526012602482015271496e76616c6964204242206164647265737360701b60448201526064015b60405180910390fd5b606a80546001600160a01b0319166001600160a01b0392909216919091179055565b60008061057560655490565b60665460408051602081018490529293506000926105b5926001600160a01b031691016040516020818303038152906040526105b090610e96565b610b02565b9050806001600160a01b0316630e2cbc3d33606760688d8d8d8d8d606a60009054906101000a90046001600160a01b03168e606954606b546040518d63ffffffff1660e01b81526004016106149c9b9a99989796959493929190610fa8565b600060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b5050604080518a815260208101899052908101879052606081018990526001600160a01b038416925033915084907f226927875e8fc1b20c8057e25b363b96220e510f97e084791642716d186327d59060800160405180910390a46106ab606580546001019055565b6000604051806101000160405280606780546106c690610ed0565b80601f01602080910402602001604051908101604052809291908181526020018280546106f290610ed0565b801561073f5780601f106107145761010080835404028352916020019161073f565b820191906000526020600020905b81548152906001019060200180831161072257829003601f168201915b50505091835250506001600160a01b0384166020820152604081018a9052606081018590526080810188905260a0810187905260c0810189905260e0018a9052606d80546001810182556000919091528151919250829160089091027f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8019081906107ca9082611096565b5060208201516001820180546001600160a01b0319166001600160a01b0390921691909117905560408201516002820155606082015160038201556080820151600482015560a0820151600582015560c0820151600682015560e082015160078201906108379082611096565b5050606c80549150600061084a83610f04565b90915550929a9950505050505050505050565b606d818154811061086d57600080fd5b906000526020600020906008020160009150905080600001805461089090610ed0565b80601f01602080910402602001604051908101604052809291908181526020018280546108bc90610ed0565b80156109095780601f106108de57610100808354040283529160200191610909565b820191906000526020600020905b8154815290600101906020018083116108ec57829003601f168201915b5050505050908060010160009054906101000a90046001600160a01b03169080600201549080600301549080600401549080600501549080600601549080600701805461095590610ed0565b80601f016020809104026020016040519081016040528092919081815260200182805461098190610ed0565b80156109ce5780601f106109a3576101008083540402835291602001916109ce565b820191906000526020600020905b8154815290600101906020018083116109b157829003601f168201915b5050505050905088565b6109e0610a51565b6001600160a01b038116610a455760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161053e565b610a4e81610ab0565b50565b33610a5a610255565b6001600160a01b0316146102535760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161053e565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528360601b60148201526e5af43d82803e903d91602b57fd5bf360881b6028820152826037826000f59150506001600160a01b03811661023b5760405162461bcd60e51b815260206004820152601760248201527f455243313136373a2063726561746532206661696c6564000000000000000000604482015260640161053e565b600060208284031215610bb457600080fd5b5035919050565b6000815180845260005b81811015610be157602081850181015186830182015201610bc5565b506000602082860101526020601f19601f83011685010191505092915050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015610cc257603f1989840301855281516101008151818652610c4f82870182610bbb565b838b01516001600160a01b0316878c0152898401518a880152606080850151908801526080808501519088015260a0848101519088015260c0808501519088015260e093840151878203948801949094529150610cae90508183610bbb565b968901969450505090860190600101610c28565b509098975050505050505050565b6001600160a01b0381168114610a4e57600080fd5b600060208284031215610cf757600080fd5b8135610d0281610cd0565b9392505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112610d3057600080fd5b813567ffffffffffffffff80821115610d4b57610d4b610d09565b604051601f8301601f19908116603f01168101908282118183101715610d7357610d73610d09565b81604052838152866020858801011115610d8c57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060c08789031215610dc557600080fd5b863567ffffffffffffffff80821115610ddd57600080fd5b610de98a838b01610d1f565b97506020890135915080821115610dff57600080fd5b50610e0c89828a01610d1f565b96999698505050506040850135946060810135946080820135945060a09091013592509050565b6000610100808352610e478184018c610bbb565b905060018060a01b038a1660208401528860408401528760608401528660808401528560a08401528460c084015282810360e0840152610e878185610bbb565b9b9a5050505050505050505050565b805160208083015191908110156104e95760001960209190910360031b1b16919050565b634e487b7160e01b600052603260045260246000fd5b600181811c90821680610ee457607f821691505b6020821081036104e957634e487b7160e01b600052602260045260246000fd5b600060018201610f2457634e487b7160e01b600052601160045260246000fd5b5060010190565b60008154610f3881610ed0565b808552602060018381168015610f555760018114610f6f57610f9d565b60ff1985168884015283151560051b880183019550610f9d565b866000528260002060005b85811015610f955781548a8201860152908301908401610f7a565b890184019650505b505050505092915050565b600060018060a01b03808f1683526101806020840152610fcc61018084018f610f2b565b8381036040850152610fde818f610f2b565b90508381036060850152610ff2818e610bbb565b90508381036080850152611006818d610bbb565b60a085019b909b525060c08301989098525060e081019590955292909416610100840152610120830152610140820192909252610160015295945050505050565b601f82111561109157600081815260208120601f850160051c8101602086101561106e5750805b601f850160051c820191505b8181101561108d5782815560010161107a565b5050505b505050565b815167ffffffffffffffff8111156110b0576110b0610d09565b6110c4816110be8454610ed0565b84611047565b602080601f8311600181146110f957600084156110e15750858301515b600019600386901b1c1916600185901b17855561108d565b600085815260208120601f198616915b8281101561112857888601518255948401946001909101908401611109565b50858210156111465787850151600019600388901b60f8161c191681555b5050505050600190811b0190555056fea2646970667358221220c3c3b529419531a6bf11a8320de9e00692d7f01cf9c06412829ed90f696825d164736f6c63430008100033000000000000000000000000eca137cea757dc499430eead875041d9f62a464d0000000000000000000000001f83b42aa2b03f01eec063afd4b3e674f97fe9e8
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000eca137cea757dc499430eead875041d9f62a464d0000000000000000000000001f83b42aa2b03f01eec063afd4b3e674f97fe9e8
-----Decoded View---------------
Arg [0] : _implementation (address): 0xeca137cea757dc499430eead875041d9f62a464d
Arg [1] : bunyBank (address): 0x1f83b42aa2b03f01eec063afd4b3e674f97fe9e8
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000eca137cea757dc499430eead875041d9f62a464d
Arg [1] : 0000000000000000000000001f83b42aa2b03f01eec063afd4b3e674f97fe9e8
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.