Source Code
Overview
ETH Balance
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 27233370 | 25 days ago | 0 ETH | ||||
| 27154502 | 27 days ago | 0 ETH | ||||
| 25022531 | 87 days ago | 0 ETH | ||||
| 24237156 | 110 days ago | 0 ETH | ||||
| 24085202 | 113 days ago | 0 ETH | ||||
| 23947824 | 117 days ago | 0 ETH | ||||
| 23905625 | 118 days ago | 0 ETH | ||||
| 23736034 | 122 days ago | 0 ETH | ||||
| 23549614 | 127 days ago | 0 ETH | ||||
| 23533110 | 127 days ago | 0 ETH | ||||
| 23475334 | 128 days ago | 0 ETH | ||||
| 23360026 | 131 days ago | 0 ETH | ||||
| 23353121 | 131 days ago | 0 ETH | ||||
| 23342774 | 132 days ago | 0 ETH | ||||
| 23335719 | 132 days ago | 0 ETH | ||||
| 23334093 | 132 days ago | 0 ETH | ||||
| 23328283 | 132 days ago | 0 ETH | ||||
| 23323833 | 132 days ago | 0 ETH | ||||
| 23321203 | 132 days ago | 0 ETH | ||||
| 23285477 | 133 days ago | 0 ETH | ||||
| 23157330 | 136 days ago | 0 ETH | ||||
| 23121645 | 137 days ago | 0 ETH | ||||
| 23040776 | 139 days ago | 0 ETH | ||||
| 22919118 | 142 days ago | 0 ETH | ||||
| 22855611 | 143 days ago | 0 ETH |
Loading...
Loading
Contract Name:
LotteryCollection
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./RandomVDFv1.sol";
import "./LotteryStructs.sol";
contract LotteryCollection is Initializable, ERC721Upgradeable, ERC721PausableUpgradeable, OwnableUpgradeable, ERC721BurnableUpgradeable, ERC721EnumerableUpgradeable {
bool private transferable;
bool private sessionWinnersFound;
uint40 public sessionEndDate;
uint40 public sessionStartDate;
bytes32 public merkleRoot;
string private _ticketDataJson;
string private _participantDataJson;
address private vdf;
ShareStructs.Reward[] public sessionRewards;
address[] public sessionParticipants; // distinct list of all participants
mapping(address => uint256) private participantsIndex;
mapping(address => bool) private endSessionTicketStorage; // number of tickets each participant owns
// Map the transaction hash to the ticket id
mapping(bytes32 => uint256) public ticketHistory;
uint256 public ticketId;
uint256 public totalTicketBurnt;
// 0: ticket
// 1: participant
// 2...(rewardCount + 2): winner
mapping(uint256 tokenId => uint256) private tokenTypes; // map from tokenId -> token type
constructor() {
_disableInitializers();
}
function initialize(
bool isTransferable,
string memory sessionName,
string memory sessionSymbol,
string memory ticketDataJson,
string memory participantDataJson,
address _vdfAddress,
uint40 endDate,
uint40 startDate
) initializer public {
sessionEndDate = endDate;
sessionStartDate = startDate;
// ticketDataJson is the common metadata for the ticket during the Lottery session
_ticketDataJson = ticketDataJson;
// participantDataJson this one is used for the recycling function after the user burn all their old tickets and receive a new one
_participantDataJson = participantDataJson;
transferable = isTransferable;
vdf = _vdfAddress;
__ERC721_init(sessionName, sessionSymbol);
__ERC721Pausable_init();
__Ownable_init();
__ERC721Burnable_init();
__ERC721Enumerable_init();
}
function claim(uint8 rewardIdx) external onlyOwner returns (bool) {
_claim(rewardIdx);
return true;
}
function getTotalRewards() public view returns (uint256){
return sessionRewards.length;
}
function newReward(
string memory dataJson,
uint256 amount,
uint256 tokenId,
address tokenAddress,
uint8 contractType
) external payable onlyOwner returns (uint256){
_activeSession();
sessionRewards.push(ShareStructs.Reward({
dataJson: dataJson,
amount: amount,
tokenId: tokenId,
tokenAddress: tokenAddress,
contractType: contractType,
claimed: false,
winner: address(0)
}));
return sessionRewards.length;
}
function updateTicketData(string memory dataJson) public onlyOwner{
_ticketDataJson = dataJson;
}
function updateParticipantData(string memory dataJson) public onlyOwner{
_participantDataJson = dataJson;
}
function newTicket(
address to,
bytes32[] memory txHashes
)
public onlyOwner startedSession returns (uint256[] memory) {
require(txHashes.length > 0, "No trxn hashes provided");
uint256[] memory tokenIds = new uint256[](txHashes.length);
for (uint256 i; i < txHashes.length; i++) {
require(ticketHistory[txHashes[i]] == 0, "Trxn already used");
uint256 tokenId = safeMint(to, 0);
tokenIds[i] = tokenId;
ticketHistory[txHashes[i]] = tokenId;
}
return tokenIds;
}
function getReward(uint8 rewardIdx) public view returns (ShareStructs.Reward memory){
return sessionRewards[rewardIdx];
}
function participantCount() public view returns (uint256) {
return sessionParticipants.length;
}
function participants(uint256 _from, uint256 _to) public view returns (ShareStructs.ParticipantAndWeight[] memory) {
ShareStructs.ParticipantAndWeight[] memory addresses = new ShareStructs.ParticipantAndWeight[](_to-_from);
uint256 count;
for (_from; _from < _to; _from++){
address p = sessionParticipants[_from];
addresses[count] = ShareStructs.ParticipantAndWeight(
p,
balanceOf(p)
);
count++;
}
return addresses;
}
function participant(uint256 idx) public view returns (ShareStructs.ParticipantAndWeight memory){
address p = sessionParticipants[idx];
return ShareStructs.ParticipantAndWeight(
p,
balanceOf(p)
);
}
function randomWinners(
bytes32[][] memory merkleProofs,
uint256[] memory proofs,
uint256[] memory winnerIndices,
uint256[] memory leafIndices
) public onlyOwner returns (address[] memory) {
_endedSession();
unpause();
require(sessionWinnersFound == false, "Session winners already found");
uint256 totalWeight = totalSupply(); // total number of tickets so far
address[] memory sessionWinners = new address[](sessionRewards.length);
if (totalWeight == 0) {
return sessionWinners;
}
for (uint256 rewardIdx; rewardIdx < sessionRewards.length; rewardIdx++) {
if (totalWeight == 0) {
break;
}
if (rewardIdx == winnerIndices.length) continue;
uint256 proof = proofs[rewardIdx];
uint256 winnerIdx = winnerIndices[rewardIdx];
address winner = sessionParticipants[winnerIdx];
uint256 leafIdx = leafIndices[rewardIdx];
require(verifyMerkleProof(merkleProofs[rewardIdx], winner, leafIdx), "Invalid merkle proof");
require(RandomVDFv1(vdf).prove(proof, rewardIdx), "Invalid proof");
uint256 ranIdx = proof % totalWeight;
for (uint256 j; j < rewardIdx; j++) {
uint256 prevIdx = winnerIndices[j];
if (prevIdx < winnerIdx) {
address prevWinner = sessionParticipants[prevIdx];
ranIdx += balanceOf(prevWinner);
}
}
require(ranIdx == leafIdx, string.concat("Winner index mismatch ", Strings.toString(rewardIdx), " ", Strings.toString(ranIdx), " ", Strings.toString(leafIdx)));
sessionRewards[rewardIdx].winner = winner;
sessionWinners[rewardIdx] = winner;
totalWeight -= balanceOf(winner);
}
for (uint256 rewardIdx; rewardIdx < sessionRewards.length; rewardIdx++) {
address winner = sessionWinners[rewardIdx];
if (winner != address(0)) {
ticketId++;
uint256 tokenId = ticketId;
_mint(winner, tokenId);
tokenTypes[tokenId] = rewardIdx + 2;
}
}
sessionWinnersFound = true;
return sessionWinners;
}
function recyclingTickets(bool mintEndSessionTicket) public {
require(sessionWinnersFound, "Method not allow yet");
_endedSession();
address ticketOwner = msg.sender;
uint256 totalTickets = balanceOf(ticketOwner); // TODO: What if owner is a winner here?
for (uint256 i = totalTickets - 1; i >= 0; i--) {
uint256 tid = tokenOfOwnerByIndex(ticketOwner, i);
if (tokenTypes[tid] == 0) burn(tid);
}
if(mintEndSessionTicket && (endSessionTicketStorage[ticketOwner] == false)) {
safeMint(ticketOwner, 1);
}
endSessionTicketStorage[ticketOwner] = true;
}
function getMaxUint() public pure returns(uint256){
unchecked{
return uint256(0) - 1;
}
}
function _claim(uint8 rewardIdx) internal {
_endedSession();
ShareStructs.Reward memory sessionReward = sessionRewards[rewardIdx];
address recipient;
if(sessionReward.winner == address(0)){
recipient = tx.origin; // Real owner of master contract
} else{
recipient = sessionReward.winner;
}
if (sessionReward.contractType == 0) {
(bool success, ) = recipient.call{value: sessionReward.amount}("");
require(success, "Transfer failed");
} else if (sessionReward.contractType == 1) {
IERC20 token = IERC20(sessionReward.tokenAddress);
token.transferFrom(address(this), recipient, sessionReward.amount);
} else if (sessionReward.contractType == 2) {
IERC721 token = IERC721(sessionReward.tokenAddress);
token.safeTransferFrom(address(this), recipient, sessionReward.tokenId);
} else if (sessionReward.contractType == 3) {
IERC1155 token = IERC1155(sessionReward.tokenAddress);
token.safeTransferFrom(address(this), recipient, sessionReward.tokenId, sessionReward.amount, "");
}
sessionRewards[rewardIdx].claimed = true;
}
function createSeeds(bytes32 _merkleRoot) public onlyOwner whenPaused {
_endedSession();
RandomVDFv1(vdf).createSeed(sessionRewards.length);
merkleRoot = _merkleRoot;
}
function _endedSession() private view {
require(sessionEndDate < block.timestamp, "Session is not ended yet");
}
modifier startedSession() {
_activeSession();
require(sessionStartDate < block.timestamp, "Session is not started yet");
_;
}
function _activeSession() private view {
require(sessionEndDate > block.timestamp, "Session ended");
}
function seeds() view public returns (uint256[] memory) {
return RandomVDFv1(vdf).getSeeds(address(this));
}
function verifyMerkleProof(bytes32[] memory proof, address winner, uint256 leafIdx) public view returns(bool){
require(merkleRoot != 0x00, "Root not found");
return MerkleProof.verify(proof, merkleRoot, keccak256(bytes.concat(keccak256(abi.encode(winner, leafIdx)))));
}
receive () payable external {}
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
view
external
returns (bytes4) {
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
function onERC1155Received(address _operator, address _from, uint256 _tokenId, uint256 _value, bytes calldata _data)
external
view
returns (bytes4)
{
return bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"));
}
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize)
internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable, ERC721PausableUpgradeable)
{
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
require(transferable || from == address(0) || from == owner(), "Ticket is not transferable");
if (from == to) {
// Nothing to do here
return;
}
if (from != address(0) && balanceOf(from) == 1) {
_removeOwner(from);
}
if (to == address(0)) {
delete tokenTypes[firstTokenId];
} else if (balanceOf(to) == 0) {
_addOwner(to);
}
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function safeMint(address to, uint256 tokenType) private returns (uint256) {
ticketId++;
uint256 tokenId = ticketId;
_safeMint(to, tokenId);
tokenTypes[tokenId] = tokenType;
return tokenId;
}
function base64Encode(string memory data) private pure returns (string memory){
return string.concat("data:application/json;base64,", Base64.encode(bytes(data)));
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721Upgradeable)
returns (string memory)
{
_requireMinted(tokenId);
uint256 tokenType = tokenTypes[tokenId];
string memory uri;
if (tokenType == 0) {
uri = base64Encode(_ticketDataJson);
} else if (tokenType == 1) {
uri = base64Encode(_participantDataJson);
} else {
uint256 rewardIdx = tokenType - 2;
uri = base64Encode(sessionRewards[rewardIdx].dataJson);
}
return uri;
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _removeOwner(address owner) private {
// Idea copied from ERC721Enumerable
uint256 lastOwnerIndex = sessionParticipants.length - 1;
uint256 ownerIndex = participantsIndex[owner];
address lastOwner = sessionParticipants[lastOwnerIndex];
sessionParticipants[ownerIndex] = lastOwner; // Move the last owner to the slot of the to-delete owner
participantsIndex[lastOwner] = ownerIndex; // Update the moved owner's index
// This also deletes the contents at the last position of the array
delete participantsIndex[owner];
sessionParticipants.pop();
}
function _addOwner(address owner) private {
participantsIndex[owner] = sessionParticipants.length;
sessionParticipants.push(owner);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
library ShareStructs {
struct Reward {
string dataJson;
uint256 amount; // (32 bytes) amount of the asset being sent
///// tokenAddress, contractType, tokenId, claimed & timestamp are stored in a single 32 byte word
uint256 tokenId; // (32 bytes) id of the token being sent (if erc721 or erc1155)
address tokenAddress; // (20 bytes) address of the asset being sent. 0x0 for native token
uint8 contractType; // (1 byte) 0 for eth, 1 for erc20, 2 for erc721, 3 for erc1155
/////
bool claimed; // (1 byte) has this deposit been claimed
address winner; // (20 bytes) address of the sender
}
struct ParticipantAndWeight{
address _address;
uint256 _weight;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import './SlothVDF.sol';
contract RandomVDFv1 {
// TODO: Update this value later
uint256 public prime = 432211379112113246928842014508850435796007;
// TODO: Alter this value based on usecase
uint256 public iterations = 1000;
// increment nonce to increase entropy
uint256 private nonce;
// address -> vdf seed
mapping(address => uint256[]) public seeds;
function createSeed(uint256 n) external payable {
// commit funds/tokens/etc here
// create a pseudo random seed as the input
require(seeds[msg.sender].length == 0, "Seed exist");
for (uint256 i; i < n;i++){
seeds[msg.sender].push(uint256(keccak256(abi.encodePacked(msg.sender, nonce++, block.timestamp, blockhash(block.number - 1)))));
}
}
function prove(uint256 proof, uint256 seedIdx) view public returns (bool) {
require(seedIdx < seeds[msg.sender].length, "Not enough seed");
// see if the proof is valid for the seed associated with the address
bool result = SlothVDF.verify(proof, seeds[msg.sender][seedIdx], prime, iterations);
// use the proof as a provable random number
// uint256 _random = proof;
return result;
}
function randomAddress(address[] memory addresses, uint256 proof, uint256 proofIdx) public view returns (address){
require(prove(proof, proofIdx), "Invalid proof");
if (addresses.length == 0){
return address(0);
}
uint256 winnerTicketId = proof % addresses.length;
return addresses[winnerTicketId];
}
function getSeeds(address seedAddress) public view returns (uint256[] memory){
return seeds[seedAddress];
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*
* _Available since v4.5._
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
/**
* Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
* https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
*/
if (data.length == 0) return "";
// Loads the table into memory
string memory table = _TABLE;
// Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
// and split into 4 numbers of 6 bits.
// The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
// - `data.length + 2` -> Round up
// - `/ 3` -> Number of 3-bytes chunks
// - `4 *` -> 4 characters for each chunk
string memory result = new string(4 * ((data.length + 2) / 3));
/// @solidity memory-safe-assembly
assembly {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 32)
// Run over the input, 3 bytes at a time
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 bytes (18 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F which is the number of
// the previous character in the ASCII table prior to the Base64 Table
// The result is then added to the table to get the character to write,
// and finally write it in the result pointer but with a left shift
// of 256 (1 byte) - 8 (1 ASCII char) = 248 bits
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
}
// When data `bytes` is not exactly 3 bytes long
// it is padded with `=` characters at the end
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _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) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _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);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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]
* ```solidity
* 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.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
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.
*
* 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.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* 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.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
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.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 {Initializable} from "../../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 = _ownerOf(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 or 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 or 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 or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @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 _ownerOf(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, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721Upgradeable.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721Upgradeable.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @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, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @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. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
/**
* @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.9.2) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proofLen - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
require(proofPos == proofLen, "MerkleProof: invalid multiproof");
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* 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 (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 IERC721Receiver {
/**
* @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.8.2) (token/ERC721/extensions/ERC721Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC721Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev ERC721 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*
* IMPORTANT: This contract does not include public pause and unpause functions. In
* addition to inheriting this contract, you must define both functions, invoking the
* {Pausable-_pause} and {Pausable-_unpause} internal functions, with appropriate
* access control, e.g. using {AccessControl} or {Ownable}. Not doing so will
* make the contract unpausable.
*/
abstract contract ERC721PausableUpgradeable is Initializable, ERC721Upgradeable, PausableUpgradeable {
function __ERC721Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __ERC721Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
require(!paused(), "ERC721Pausable: token transfer while paused");
}
/**
* @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 (last updated v4.9.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import {Initializable} from "../../../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 {
// 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;
function __ERC721Enumerable_init() internal onlyInitializing {
}
function __ERC721Enumerable_init_unchained() internal onlyInitializing {
}
/**
* @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 See {ERC721-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
if (batchSize > 1) {
// Will only trigger during construction. Batch transferring (minting) is not available afterwards.
revert("ERC721Enumerable: consecutive transfers not supported");
}
uint256 tokenId = firstTokenId;
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.8.0) (token/ERC721/extensions/ERC721Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC721Upgradeable.sol";
import "../../../utils/ContextUpgradeable.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be burned (destroyed).
*/
abstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable {
function __ERC721Burnable_init() internal onlyInitializing {
}
function __ERC721Burnable_init_unchained() internal onlyInitializing {
}
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_burn(tokenId);
}
/**
* @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
// 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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
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);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
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;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @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 (last updated v4.9.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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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 (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @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 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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _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) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @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] = _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);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* 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 (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 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 v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import {Initializable} from "../../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 (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
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);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
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;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// 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
// 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 IERC165 {
/**
* @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
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @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 (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);
}{
"optimizer": {
"enabled": true,
"runs": 100
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","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":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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"rewardIdx","type":"uint8"}],"name":"claim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"createSeeds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxUint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint8","name":"rewardIdx","type":"uint8"}],"name":"getReward","outputs":[{"components":[{"internalType":"string","name":"dataJson","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"contractType","type":"uint8"},{"internalType":"bool","name":"claimed","type":"bool"},{"internalType":"address","name":"winner","type":"address"}],"internalType":"struct ShareStructs.Reward","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isTransferable","type":"bool"},{"internalType":"string","name":"sessionName","type":"string"},{"internalType":"string","name":"sessionSymbol","type":"string"},{"internalType":"string","name":"ticketDataJson","type":"string"},{"internalType":"string","name":"participantDataJson","type":"string"},{"internalType":"address","name":"_vdfAddress","type":"address"},{"internalType":"uint40","name":"endDate","type":"uint40"},{"internalType":"uint40","name":"startDate","type":"uint40"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"dataJson","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"contractType","type":"uint8"}],"name":"newReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32[]","name":"txHashes","type":"bytes32[]"}],"name":"newTicket","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"idx","type":"uint256"}],"name":"participant","outputs":[{"components":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_weight","type":"uint256"}],"internalType":"struct ShareStructs.ParticipantAndWeight","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"participantCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_to","type":"uint256"}],"name":"participants","outputs":[{"components":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_weight","type":"uint256"}],"internalType":"struct ShareStructs.ParticipantAndWeight[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[][]","name":"merkleProofs","type":"bytes32[][]"},{"internalType":"uint256[]","name":"proofs","type":"uint256[]"},{"internalType":"uint256[]","name":"winnerIndices","type":"uint256[]"},{"internalType":"uint256[]","name":"leafIndices","type":"uint256[]"}],"name":"randomWinners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"mintEndSessionTicket","type":"bool"}],"name":"recyclingTickets","outputs":[],"stateMutability":"nonpayable","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":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"seeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sessionEndDate","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sessionParticipants","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sessionRewards","outputs":[{"internalType":"string","name":"dataJson","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint8","name":"contractType","type":"uint8"},{"internalType":"bool","name":"claimed","type":"bool"},{"internalType":"address","name":"winner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sessionStartDate","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"ticketHistory","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTicketBurnt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"dataJson","type":"string"}],"name":"updateParticipantData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"dataJson","type":"string"}],"name":"updateTicketData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"winner","type":"address"},{"internalType":"uint256","name":"leafIdx","type":"uint256"}],"name":"verifyMerkleProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6148e280620000f36000396000f3fe6080604052600436106102ad5760003560e01c8063715018a611610165578063a6a913f6116100cc578063e722a8d711610085578063e722a8d71461088f578063e985e9c5146108a4578063f23a6e61146108c4578063f2fde38b1461090a578063f70bbc521461092a578063f9f0164a14610950578063fd1c82501461096757600080fd5b8063a6a913f6146107cb578063af2f13e214610806578063b88d4fde14610819578063c75ff55a14610839578063c87b56dd14610859578063e627f2db1461087957600080fd5b80638da5cb5b1161011e5780638da5cb5b1461071657806395d4063f1461073457806395d89b41146107545780639a6a327c146107695780639b7e11c714610796578063a22cb465146107ab57600080fd5b8063715018a6146106515780637669a2a8146106665780637bd67868146106865780637fac96ac146106a657806381fb1fb4146106d45780638456cb591461070157600080fd5b80633a0277d9116102145780634f6ccce7116101cd5780634f6ccce714610559578063565b9a2a146105795780635c975abb146105ac578063616fc704146105c45780636352211e146105f1578063705c1a111461061157806370a082311461063157600080fd5b80633a0277d91461048a5780633f4ba83a146104b757806342842e0e146104cc57806342966c68146104ec5780634821c1bc1461050c5780634b07954a1461052c57600080fd5b806318160ddd1161026657806318160ddd146103dd5780631f040297146103fd57806323b872dd1461041d5780632eb4a7ab1461043d5780632f745c5914610454578063362f04c01461047457600080fd5b806301ffc9a7146102b957806302a57a45146102ee57806306fdde0314610310578063081812fc14610332578063095ea7b31461035f578063150b7a021461037f57600080fd5b366102b457005b600080fd5b3480156102c557600080fd5b506102d96102d4366004613853565b61097e565b60405190151581526020015b60405180910390f35b3480156102fa57600080fd5b5061030e610309366004613870565b61098f565b005b34801561031c57600080fd5b50610325610a19565b6040516102e591906138d9565b34801561033e57600080fd5b5061035261034d366004613870565b610aab565b6040516102e591906138ec565b34801561036b57600080fd5b5061030e61037a366004613917565b610ad2565b34801561038b57600080fd5b506103c461039a366004613989565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b031990911681526020016102e5565b3480156103e957600080fd5b50610161545b6040519081526020016102e5565b34801561040957600080fd5b5061030e610418366004613ae2565b610bec565b34801561042957600080fd5b5061030e610438366004613bd1565b610db0565b34801561044957600080fd5b506103ef6101925481565b34801561046057600080fd5b506103ef61046f366004613917565b610de2565b34801561048057600080fd5b50610197546103ef565b34801561049657600080fd5b506104aa6104a5366004613c9b565b610e79565b6040516102e59190613db7565b3480156104c357600080fd5b5061030e611369565b3480156104d857600080fd5b5061030e6104e7366004613bd1565b61137b565b3480156104f857600080fd5b5061030e610507366004613870565b611396565b34801561051857600080fd5b5061030e610527366004613e04565b6113c7565b34801561053857600080fd5b5061054c610547366004613870565b61147c565b6040516102e59190613e21565b34801561056557600080fd5b506103ef610574366004613870565b6114e2565b34801561058557600080fd5b50610599610594366004613870565b611577565b6040516102e59796959493929190613e41565b3480156105b857600080fd5b5060975460ff166102d9565b3480156105d057600080fd5b506105e46105df366004613e93565b611669565b6040516102e59190613ee0565b3480156105fd57600080fd5b5061035261060c366004613870565b611867565b34801561061d57600080fd5b5061035261062c366004613870565b61189c565b34801561063d57600080fd5b506103ef61064c366004613f18565b6118c7565b34801561065d57600080fd5b5061030e61194d565b34801561067257600080fd5b506102d9610681366004613f33565b61195f565b34801561069257600080fd5b5061030e6106a1366004613f79565b611a03565b3480156106b257600080fd5b506103ef6106c1366004613870565b61019a6020526000908152604090205481565b3480156106e057600080fd5b506106f46106ef366004613fad565b611a1c565b6040516102e59190613fcf565b34801561070d57600080fd5b5061030e611b1f565b34801561072257600080fd5b5060fb546001600160a01b0316610352565b34801561074057600080fd5b506102d961074f366004614040565b611b2f565b34801561076057600080fd5b50610325611b4b565b34801561077557600080fd5b50610789610784366004614040565b611b5a565b6040516102e5919061405b565b3480156107a257600080fd5b506000196103ef565b3480156107b757600080fd5b5061030e6107c63660046140d3565b611cb4565b3480156107d757600080fd5b50610191546107f09062010000900464ffffffffff1681565b60405164ffffffffff90911681526020016102e5565b6103ef61081436600461410a565b611cbf565b34801561082557600080fd5b5061030e61083436600461417b565b611de8565b34801561084557600080fd5b5061030e610854366004613f79565b611e20565b34801561086557600080fd5b50610325610874366004613870565b611e35565b34801561088557600080fd5b50610196546103ef565b34801561089b57600080fd5b506105e4611f5c565b3480156108b057600080fd5b506102d96108bf3660046141ea565b611fd8565b3480156108d057600080fd5b506103c46108df36600461421d565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b34801561091657600080fd5b5061030e610925366004613f18565b612006565b34801561093657600080fd5b50610191546107f090600160381b900464ffffffffff1681565b34801561095c57600080fd5b506103ef61019b5481565b34801561097357600080fd5b506103ef61019c5481565b60006109898261207c565b92915050565b6109976120a1565b61099f6120fb565b6109a7612144565b6101955461019654604051638c0f463560e01b81526001600160a01b0390921691638c0f4635916109de9160040190815260200190565b600060405180830381600087803b1580156109f857600080fd5b505af1158015610a0c573d6000803e3d6000fd5b5050506101929190915550565b606060658054610a2890614294565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5490614294565b8015610aa15780601f10610a7657610100808354040283529160200191610aa1565b820191906000526020600020905b815481529060010190602001808311610a8457829003601f168201915b5050505050905090565b6000610ab68261219f565b506000908152606960205260409020546001600160a01b031690565b6000610add82611867565b9050806001600160a01b0316836001600160a01b031603610b4f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610b6b5750610b6b8133611fd8565b610bdd5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610b46565b610be783836121c4565b505050565b600054610100900460ff1615808015610c0c5750600054600160ff909116105b80610c265750303b158015610c26575060005460ff166001145b610c895760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b46565b6000805460ff191660011790558015610cac576000805461ff0019166101001790555b610191805464ffffffffff848116600160381b0264ffffffffff60381b199187166201000002919091166bffffffffffffffffffff00001990921691909117179055610193610cfb878261431c565b50610194610d09868261431c565b50610191805460ff19168a151517905561019580546001600160a01b0319166001600160a01b038616179055610d3f8888612232565b610d47612263565b610d4f612292565b610d576122c1565b610d5f6122c1565b8015610da5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610dbb335b826122e8565b610dd75760405162461bcd60e51b8152600401610b46906143db565b610be7838383612346565b6000610ded836118c7565b8210610e4f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610b46565b506001600160a01b0391909116600090815261015f60209081526040808320938352929052205490565b6060610e836120a1565b610e8b612144565b610e93611369565b61019154610100900460ff1615610eec5760405162461bcd60e51b815260206004820152601d60248201527f53657373696f6e2077696e6e65727320616c726561647920666f756e640000006044820152606401610b46565b6000610ef86101615490565b610196549091506000906001600160401b03811115610f1957610f19613a10565b604051908082528060200260200182016040528015610f42578160200160208202803683370190505b50905081600003610f565791506113619050565b60005b610196548110156112b15782156112b1578551811461129f576000878281518110610f8657610f86614428565b602002602001015190506000878381518110610fa457610fa4614428565b6020026020010151905060006101978281548110610fc457610fc4614428565b600091825260208220015489516001600160a01b039091169250899086908110610ff057610ff0614428565b6020026020010151905061101e8c868151811061100f5761100f614428565b6020026020010151838361195f565b6110615760405162461bcd60e51b815260206004820152601460248201527324b73b30b634b21036b2b935b63290383937b7b360611b6044820152606401610b46565b61019554604051632d3e27f760e01b815260048101869052602481018790526001600160a01b0390911690632d3e27f790604401602060405180830381865afa1580156110b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d6919061443e565b6111125760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610b46565b600061111e8886614471565b905060005b868110156111a85760008c828151811061113f5761113f614428565b6020026020010151905085811015611195576000610197828154811061116757611167614428565b6000918252602090912001546001600160a01b03169050611187816118c7565b611191908561449b565b9350505b50806111a0816144ae565b915050611123565b508181146111b5876124a5565b6111be836124a5565b6111c7856124a5565b6040516020016111d9939291906144c7565b604051602081830303815290604052906112065760405162461bcd60e51b8152600401610b4691906138d9565b5082610196878154811061121c5761121c614428565b906000526020600020906005020160040160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508287878151811061126457611264614428565b60200260200101906001600160a01b031690816001600160a01b03168152505061128d836118c7565b6112979089614543565b975050505050505b806112a9816144ae565b915050610f59565b5060005b6101965481101561134c5760008282815181106112d4576112d4614428565b6020026020010151905060006001600160a01b0316816001600160a01b0316146113395761019b8054906000611309836144ae565b909155505061019b5461131c8282612537565b61132783600261449b565b600091825261019d6020526040909120555b5080611344816144ae565b9150506112b5565b50610191805461ff0019166101001790559150505b949350505050565b6113716120a1565b611379612640565b565b610be783838360405180602001604052806000815250611de8565b61139f33610db5565b6113bb5760405162461bcd60e51b8152600401610b46906143db565b6113c48161268c565b50565b61019154610100900460ff166114165760405162461bcd60e51b815260206004820152601460248201527313595d1a1bd9081b9bdd08185b1b1bddc81e595d60621b6044820152606401610b46565b61141e612144565b33600061142a826118c7565b90506000611439600183614543565b90505b60006114488483610de2565b600081815261019d6020526040812054919250036114695761146981611396565b508061147481614556565b91505061143c565b6040805180820190915260008082526020820152600061019783815481106114a6576114a6614428565b60009182526020918290200154604080518082019091526001600160a01b0390911680825292509081016114d9836118c7565b90529392505050565b60006114ee6101615490565b82106115515760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610b46565b610161828154811061156557611565614428565b90600052602060002001549050919050565b610196818154811061158857600080fd5b90600052602060002090600502016000915090508060000180546115ab90614294565b80601f01602080910402602001604051908101604052809291908181526020018280546115d790614294565b80156116245780601f106115f957610100808354040283529160200191611624565b820191906000526020600020905b81548152906001019060200180831161160757829003601f168201915b505050600184015460028501546003860154600490960154949591949093506001600160a01b03808316935060ff600160a01b8404811693600160a81b900416911687565b60606116736120a1565b61167b61275b565b6101915442600160381b90910464ffffffffff16106116dc5760405162461bcd60e51b815260206004820152601a60248201527f53657373696f6e206973206e6f742073746172746564207965740000000000006044820152606401610b46565b60008251116117275760405162461bcd60e51b8152602060048201526017602482015276139bc81d1c9e1b881a185cda195cc81c1c9bdd9a591959604a1b6044820152606401610b46565b600082516001600160401b0381111561174257611742613a10565b60405190808252806020026020018201604052801561176b578160200160208202803683370190505b50905060005b835181101561185f5761019a600085838151811061179157611791614428565b60200260200101518152602001908152602001600020546000146117eb5760405162461bcd60e51b8152602060048201526011602482015270151c9e1b88185b1c9958591e481d5cd959607a1b6044820152606401610b46565b60006117f886600061271d565b90508083838151811061180d5761180d614428565b6020026020010181815250508061019a600087858151811061183157611831614428565b6020026020010151815260200190815260200160002081905550508080611857906144ae565b915050611771565b509392505050565b6000818152606760205260408120546001600160a01b0316806109895760405162461bcd60e51b8152600401610b469061456d565b61019781815481106118ad57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006001600160a01b0382166119315760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610b46565b506001600160a01b031660009081526068602052604090205490565b6119556120a1565b61137960006127ab565b6101925460009081036119a55760405162461bcd60e51b815260206004820152600e60248201526d149bdbdd081b9bdd08199bdd5b9960921b6044820152606401610b46565b61019254604080516001600160a01b038616602082015290810184905261136191869160600160408051601f1981840301815282825280516020918201209083015201604051602081830303815290604052805190602001206127fd565b611a0b6120a1565b610194611a18828261431c565b5050565b60606000611a2a8484614543565b6001600160401b03811115611a4157611a41613a10565b604051908082528060200260200182016040528015611a8657816020015b6040805180820190915260008082526020820152815260200190600190039081611a5f5790505b50905060005b8385101561185f5760006101978681548110611aaa57611aaa614428565b60009182526020918290200154604080518082019091526001600160a01b039091168082529250908101611add836118c7565b815250838381518110611af257611af2614428565b60200260200101819052508180611b08906144ae565b925050508480611b17906144ae565b955050611a8c565b611b276120a1565b611379612813565b6000611b396120a1565b611b4282612850565b5060015b919050565b606060668054610a2890614294565b6040805160e081018252606080825260006020830181905292820183905281018290526080810182905260a0810182905260c08101919091526101968260ff1681548110611baa57611baa614428565b90600052602060002090600502016040518060e0016040529081600082018054611bd390614294565b80601f0160208091040260200160405190810160405280929190818152602001828054611bff90614294565b8015611c4c5780601f10611c2157610100808354040283529160200191611c4c565b820191906000526020600020905b815481529060010190602001808311611c2f57829003601f168201915b5050509183525050600182015460208201526002820154604082015260038201546001600160a01b03808216606084015260ff600160a01b830481166080850152600160a81b909204909116151560a083015260049092015490911660c09091015292915050565b611a18338383612c32565b6000611cc96120a1565b611cd161275b565b6040805160e081018252878152602081018790529081018590526001600160a01b038416606082015260ff83166080820152600060a0820181905260c0820181905261019680546001810182559152815160059091027f828feda00a4b64eb35101b6df8f6c29717b1ea6bae5dd03d3ddada8de0a9e7cb01908190611d56908261431c565b5060208201516001820155604082015160028201556060820151600382018054608085015160a08601511515600160a81b0260ff60a81b1960ff909216600160a01b026001600160a81b03199093166001600160a01b0395861617929092171617905560c09092015160049091018054919092166001600160a01b031991909116179055506101965495945050505050565b611df233836122e8565b611e0e5760405162461bcd60e51b8152600401610b46906143db565b611e1a84848484612cfc565b50505050565b611e286120a1565b610193611a18828261431c565b6060611e408261219f565b600082815261019d602052604081205490606090829003611ef657611eef6101938054611e6c90614294565b80601f0160208091040260200160405190810160405280929190818152602001828054611e9890614294565b8015611ee55780601f10611eba57610100808354040283529160200191611ee5565b820191906000526020600020905b815481529060010190602001808311611ec857829003601f168201915b5050505050612d2f565b9050611f55565b81600103611f0f57611eef6101948054611e6c90614294565b6000611f1c600284614543565b9050611f516101968281548110611f3557611f35614428565b90600052602060002090600502016000018054611e6c90614294565b9150505b9392505050565b61019554604051632c9bf44560e11b81526060916001600160a01b031690635937e88a90611f8e9030906004016138ec565b600060405180830381865afa158015611fab573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611fd3919081019061459f565b905090565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b61200e6120a1565b6001600160a01b0381166120735760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b46565b6113c4816127ab565b60006001600160e01b0319821663780e9d6360e01b1480610989575061098982612d60565b60fb546001600160a01b031633146113795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b46565b60975460ff166113795760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b46565b61019154426201000090910464ffffffffff16106113795760405162461bcd60e51b815260206004820152601860248201527714d95cdcda5bdb881a5cc81b9bdd08195b991959081e595d60421b6044820152606401610b46565b6121a881612db0565b6113c45760405162461bcd60e51b8152600401610b469061456d565b600081815260696020526040902080546001600160a01b0319166001600160a01b03841690811790915581906121f982611867565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600054610100900460ff166122595760405162461bcd60e51b8152600401610b469061462f565b611a188282612dcd565b600054610100900460ff1661228a5760405162461bcd60e51b8152600401610b469061462f565b611379612e0d565b600054610100900460ff166122b95760405162461bcd60e51b8152600401610b469061462f565b611379612e40565b600054610100900460ff166113795760405162461bcd60e51b8152600401610b469061462f565b6000806122f483611867565b9050806001600160a01b0316846001600160a01b0316148061231b575061231b8185611fd8565b806113615750836001600160a01b031661233484610aab565b6001600160a01b031614949350505050565b826001600160a01b031661235982611867565b6001600160a01b03161461237f5760405162461bcd60e51b8152600401610b469061467a565b6001600160a01b0382166123e15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610b46565b6123ee8383836001612e70565b826001600160a01b031661240182611867565b6001600160a01b0316146124275760405162461bcd60e51b8152600401610b469061467a565b600081815260696020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652606885528386208054600019019055908716808652838620805460010190558686526067909452828520805490921684179091559051849360008051602061488d83398151915291a4505050565b606060006124b283612fd7565b60010190506000816001600160401b038111156124d1576124d1613a10565b6040519080825280601f01601f1916602001820160405280156124fb576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461250557509392505050565b6001600160a01b03821661258d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b46565b61259681612db0565b156125b35760405162461bcd60e51b8152600401610b46906146bf565b6125c1600083836001612e70565b6125ca81612db0565b156125e75760405162461bcd60e51b8152600401610b46906146bf565b6001600160a01b038216600081815260686020908152604080832080546001019055848352606790915280822080546001600160a01b03191684179055518392919060008051602061488d833981519152908290a45050565b6126486120fb565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161268291906138ec565b60405180910390a1565b600061269782611867565b90506126a7816000846001612e70565b6126b082611867565b600083815260696020908152604080832080546001600160a01b03199081169091556001600160a01b03851680855260688452828520805460001901905587855260679093528184208054909116905551929350849260008051602061488d833981519152908390a45050565b61019b80546000918261272f836144ae565b909155505061019b5461274284826130af565b600081815261019d602052604090209290925550919050565b61019154426201000090910464ffffffffff16116113795760405162461bcd60e51b815260206004820152600d60248201526c14d95cdcda5bdb88195b991959609a1b6044820152606401610b46565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008261280a85846130c9565b14949350505050565b61281b61310e565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126753390565b612858612144565b60006101968260ff168154811061287157612871614428565b90600052602060002090600502016040518060e001604052908160008201805461289a90614294565b80601f01602080910402602001604051908101604052809291908181526020018280546128c690614294565b80156129135780601f106128e857610100808354040283529160200191612913565b820191906000526020600020905b8154815290600101906020018083116128f657829003601f168201915b5050509183525050600182015460208201526002820154604082015260038201546001600160a01b03808216606084015260ff600160a01b830481166080850152600160a81b909204909116151560a0830152600490920154821660c09182015282015191925060009116612989575032612990565b5060c08101515b816080015160ff16600003612a3b5760208201516040516000916001600160a01b038416918381818185875af1925050503d80600081146129ed576040519150601f19603f3d011682016040523d82523d6000602084013e6129f2565b606091505b5050905080612a355760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610b46565b50612bec565b816080015160ff16600103612acd57606082015160208301516040516323b872dd60e01b81526001600160a01b038316916323b872dd91612a839130918791906004016146f6565b6020604051808303816000875af1158015612aa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac6919061443e565b5050612bec565b816080015160ff16600203612b4d5760608201516040808401519051632142170760e11b81526001600160a01b038316916342842e0e91612b159130918791906004016146f6565b600060405180830381600087803b158015612b2f57600080fd5b505af1158015612b43573d6000803e3d6000fd5b5050505050612bec565b816080015160ff16600303612bec57606082015160408084015160208501519151637921219560e11b81523060048201526001600160a01b0385811660248301526044820192909252606481019290925260a06084830152600060a483015282169063f242432a9060c401600060405180830381600087803b158015612bd257600080fd5b505af1158015612be6573d6000803e3d6000fd5b50505050505b60016101968460ff1681548110612c0557612c05614428565b906000526020600020906005020160030160156101000a81548160ff021916908315150217905550505050565b816001600160a01b0316836001600160a01b031603612c8f5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610b46565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612d07848484612346565b612d1384848484613154565b611e1a5760405162461bcd60e51b8152600401610b469061471a565b6060612d3a82613252565b604051602001612d4a919061476c565b6040516020818303038152906040529050919050565b60006001600160e01b031982166380ac58cd60e01b1480612d9157506001600160e01b03198216635b5e139f60e01b145b8061098957506301ffc9a760e01b6001600160e01b0319831614610989565b6000908152606760205260409020546001600160a01b0316151590565b600054610100900460ff16612df45760405162461bcd60e51b8152600401610b469061462f565b6065612e00838261431c565b506066610be7828261431c565b600054610100900460ff16612e345760405162461bcd60e51b8152600401610b469061462f565b6097805460ff19169055565b600054610100900460ff16612e675760405162461bcd60e51b8152600401610b469061462f565b611379336127ab565b612e7c848484846133a4565b6101915460ff1680612e9557506001600160a01b038416155b80612ead575060fb546001600160a01b038581169116145b612ef95760405162461bcd60e51b815260206004820152601a60248201527f5469636b6574206973206e6f74207472616e7366657261626c650000000000006044820152606401610b46565b826001600160a01b0316846001600160a01b03160315611e1a576001600160a01b03841615801590612f335750612f2f846118c7565b6001145b15612f4157612f41846134e6565b6001600160a01b038316612f6457600082815261019d6020526040812055611e1a565b612f6d836118c7565b600003611e1a5761019780546001600160a01b038516600081815261019860205260408120839055600183018455929092527f3ea4d693734e62a1b4642df418cf4aae0e5ba336a2d6024b2d33585611a4e2eb0180546001600160a01b0319169091179055611e1a565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106130165772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613042576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061306057662386f26fc10000830492506010015b6305f5e1008310613078576305f5e100830492506008015b612710831061308c57612710830492506004015b6064831061309e576064830492506002015b600a83106109895760010192915050565b611a188282604051806020016040528060008152506135da565b600081815b845181101561185f576130fa828683815181106130ed576130ed614428565b602002602001015161360d565b915080613106816144ae565b9150506130ce565b60975460ff16156113795760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b46565b60006001600160a01b0384163b1561324a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906131989033908990889088906004016147b1565b6020604051808303816000875af19250505080156131d3575060408051601f3d908101601f191682019092526131d0918101906147ee565b60015b613230573d808015613201576040519150601f19603f3d011682016040523d82523d6000602084013e613206565b606091505b5080516000036132285760405162461bcd60e51b8152600401610b469061471a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611361565b506001611361565b6060815160000361327157505060408051602081019091526000815290565b600060405180606001604052806040815260200161484d60409139905060006003845160026132a0919061449b565b6132aa919061480b565b6132b590600461481f565b6001600160401b038111156132cc576132cc613a10565b6040519080825280601f01601f1916602001820160405280156132f6576020820181803683370190505b509050600182016020820185865187015b80821015613362576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250613307565b505060038651066001811461337e576002811461339157613399565b603d6001830353603d6002830353613399565b603d60018303535b509195945050505050565b6133b084848484613639565b600181111561341f5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610b46565b816001600160a01b03851661347d57613478816101618054600083815261016260205260408120829055600182018355919091527fafbb1c043347995df017ce3291b765e028ad5f784d2aa00c3f5e073760a4de8b0155565b6134a0565b836001600160a01b0316856001600160a01b0316146134a0576134a085826136a0565b6001600160a01b0384166134bc576134b781613742565b6134df565b846001600160a01b0316846001600160a01b0316146134df576134df84826137f7565b5050505050565b610197546000906134f990600190614543565b6001600160a01b03831660009081526101986020526040812054610197805493945090928490811061352d5761352d614428565b60009182526020909120015461019780546001600160a01b03909216925082918490811061355d5761355d614428565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790558383168252610198905260408082208590559186168152908120556101978054806135b2576135b2614836565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b6135e48383612537565b6135f16000848484613154565b610be75760405162461bcd60e51b8152600401610b469061471a565b6000818310613629576000828152602084905260409020611f55565b5060009182526020526040902090565b60975460ff1615611e1a5760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610b46565b600060016136ad846118c7565b6136b79190614543565b6000838152610160602052604090205490915080821461370d576001600160a01b038416600090815261015f60209081526040808320858452825280832054848452818420819055835261016090915290208190555b506000918252610160602090815260408084208490556001600160a01b03909416835261015f81528383209183525290812055565b6101615460009061375590600190614543565b60008381526101626020526040812054610161805493945090928490811061377f5761377f614428565b906000526020600020015490508061016183815481106137a1576137a1614428565b600091825260208083209091019290925582815261016290915260408082208490558582528120556101618054806137db576137db614836565b6001900381819060005260206000200160009055905550505050565b6000613802836118c7565b6001600160a01b03909316600090815261015f6020908152604080832086845282528083208590559382526101609052919091209190915550565b6001600160e01b0319811681146113c457600080fd5b60006020828403121561386557600080fd5b8135611f558161383d565b60006020828403121561388257600080fd5b5035919050565b60005b838110156138a457818101518382015260200161388c565b50506000910152565b600081518084526138c5816020860160208601613889565b601f01601f19169290920160200192915050565b602081526000611f5560208301846138ad565b6001600160a01b0391909116815260200190565b80356001600160a01b0381168114611b4657600080fd5b6000806040838503121561392a57600080fd5b61393383613900565b946020939093013593505050565b60008083601f84011261395357600080fd5b5081356001600160401b0381111561396a57600080fd5b60208301915083602082850101111561398257600080fd5b9250929050565b6000806000806000608086880312156139a157600080fd5b6139aa86613900565b94506139b860208701613900565b93506040860135925060608601356001600160401b038111156139da57600080fd5b6139e688828901613941565b969995985093965092949392505050565b80151581146113c457600080fd5b8035611b46816139f7565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613a4e57613a4e613a10565b604052919050565b60006001600160401b03831115613a6f57613a6f613a10565b613a82601f8401601f1916602001613a26565b9050828152838383011115613a9657600080fd5b828260208301376000602084830101529392505050565b600082601f830112613abe57600080fd5b611f5583833560208501613a56565b803564ffffffffff81168114611b4657600080fd5b600080600080600080600080610100898b031215613aff57600080fd5b613b0889613a05565b975060208901356001600160401b0380821115613b2457600080fd5b613b308c838d01613aad565b985060408b0135915080821115613b4657600080fd5b613b528c838d01613aad565b975060608b0135915080821115613b6857600080fd5b613b748c838d01613aad565b965060808b0135915080821115613b8a57600080fd5b50613b978b828c01613aad565b945050613ba660a08a01613900565b9250613bb460c08a01613acd565b9150613bc260e08a01613acd565b90509295985092959890939650565b600080600060608486031215613be657600080fd5b613bef84613900565b9250613bfd60208501613900565b9150604084013590509250925092565b60006001600160401b03821115613c2657613c26613a10565b5060051b60200190565b600082601f830112613c4157600080fd5b81356020613c56613c5183613c0d565b613a26565b82815260059290921b84018101918181019086841115613c7557600080fd5b8286015b84811015613c905780358352918301918301613c79565b509695505050505050565b60008060008060808587031215613cb157600080fd5b84356001600160401b0380821115613cc857600080fd5b818701915087601f830112613cdc57600080fd5b81356020613cec613c5183613c0d565b82815260059290921b8401810191818101908b841115613d0b57600080fd5b8286015b84811015613d4357803586811115613d275760008081fd5b613d358e86838b0101613c30565b845250918301918301613d0f565b5098505088013592505080821115613d5a57600080fd5b613d6688838901613c30565b94506040870135915080821115613d7c57600080fd5b613d8888838901613c30565b93506060870135915080821115613d9e57600080fd5b50613dab87828801613c30565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b81811015613df85783516001600160a01b031683529284019291840191600101613dd3565b50909695505050505050565b600060208284031215613e1657600080fd5b8135611f55816139f7565b81516001600160a01b031681526020808301519082015260408101610989565b60e081526000613e5460e083018a6138ad565b60208301989098525060408101959095526001600160a01b03938416606086015260ff929092166080850152151560a08401521660c090910152919050565b60008060408385031215613ea657600080fd5b613eaf83613900565b915060208301356001600160401b03811115613eca57600080fd5b613ed685828601613c30565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613df857835183529284019291840191600101613efc565b600060208284031215613f2a57600080fd5b611f5582613900565b600080600060608486031215613f4857600080fd5b83356001600160401b03811115613f5e57600080fd5b613f6a86828701613c30565b935050613bfd60208501613900565b600060208284031215613f8b57600080fd5b81356001600160401b03811115613fa157600080fd5b61136184828501613aad565b60008060408385031215613fc057600080fd5b50508035926020909101359150565b602080825282518282018190526000919060409081850190868401855b828110156140225761401284835180516001600160a01b03168252602090810151910152565b9284019290850190600101613fec565b5091979650505050505050565b803560ff81168114611b4657600080fd5b60006020828403121561405257600080fd5b611f558261402f565b602081526000825160e060208401526140786101008401826138ad565b90506020840151604084015260408401516060840152606084015160018060a01b03808216608086015260ff60808701511660a086015260a0860151151560c08601528060c08701511660e086015250508091505092915050565b600080604083850312156140e657600080fd5b6140ef83613900565b915060208301356140ff816139f7565b809150509250929050565b600080600080600060a0868803121561412257600080fd5b85356001600160401b0381111561413857600080fd5b61414488828901613aad565b955050602086013593506040860135925061416160608701613900565b915061416f6080870161402f565b90509295509295909350565b6000806000806080858703121561419157600080fd5b61419a85613900565b93506141a860208601613900565b92506040850135915060608501356001600160401b038111156141ca57600080fd5b8501601f810187136141db57600080fd5b613dab87823560208401613a56565b600080604083850312156141fd57600080fd5b61420683613900565b915061421460208401613900565b90509250929050565b60008060008060008060a0878903121561423657600080fd5b61423f87613900565b955061424d60208801613900565b9450604087013593506060870135925060808701356001600160401b0381111561427657600080fd5b61428289828a01613941565b979a9699509497509295939492505050565b600181811c908216806142a857607f821691505b6020821081036142c857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610be757600081815260208120601f850160051c810160208610156142f55750805b601f850160051c820191505b8181101561431457828155600101614301565b505050505050565b81516001600160401b0381111561433557614335613a10565b614349816143438454614294565b846142ce565b602080601f83116001811461437e57600084156143665750858301515b600019600386901b1c1916600185901b178555614314565b600085815260208120601f198616915b828110156143ad5788860151825594840194600190910190840161438e565b50858210156143cb5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561445057600080fd5b8151611f55816139f7565b634e487b7160e01b600052601260045260246000fd5b6000826144805761448061445b565b500690565b634e487b7160e01b600052601160045260246000fd5b8082018082111561098957610989614485565b6000600182016144c0576144c0614485565b5060010190565b7502bb4b73732b91034b73232bc1036b4b9b6b0ba31b4160551b8152600084516144f8816016850160208901613889565b8083019050600160fd1b806016830152855161451b816017850160208a01613889565b60179201918201528351614536816018840160208801613889565b0160180195945050505050565b8181038181111561098957610989614485565b60008161456557614565614485565b506000190190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b600060208083850312156145b257600080fd5b82516001600160401b038111156145c857600080fd5b8301601f810185136145d957600080fd5b80516145e7613c5182613c0d565b81815260059190911b8201830190838101908783111561460657600080fd5b928401925b828410156146245783518252928401929084019061460b565b979650505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516147a481601d850160208701613889565b91909101601d0192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906147e4908301846138ad565b9695505050505050565b60006020828403121561480057600080fd5b8151611f558161383d565b60008261481a5761481a61445b565b500490565b808202811582820484141761098957610989614485565b634e487b7160e01b600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202c44493d497081ebf475705a89735be01466de1ecbbb27a552c5b9b04c34fc2764736f6c63430008130033
Deployed Bytecode
0x6080604052600436106102ad5760003560e01c8063715018a611610165578063a6a913f6116100cc578063e722a8d711610085578063e722a8d71461088f578063e985e9c5146108a4578063f23a6e61146108c4578063f2fde38b1461090a578063f70bbc521461092a578063f9f0164a14610950578063fd1c82501461096757600080fd5b8063a6a913f6146107cb578063af2f13e214610806578063b88d4fde14610819578063c75ff55a14610839578063c87b56dd14610859578063e627f2db1461087957600080fd5b80638da5cb5b1161011e5780638da5cb5b1461071657806395d4063f1461073457806395d89b41146107545780639a6a327c146107695780639b7e11c714610796578063a22cb465146107ab57600080fd5b8063715018a6146106515780637669a2a8146106665780637bd67868146106865780637fac96ac146106a657806381fb1fb4146106d45780638456cb591461070157600080fd5b80633a0277d9116102145780634f6ccce7116101cd5780634f6ccce714610559578063565b9a2a146105795780635c975abb146105ac578063616fc704146105c45780636352211e146105f1578063705c1a111461061157806370a082311461063157600080fd5b80633a0277d91461048a5780633f4ba83a146104b757806342842e0e146104cc57806342966c68146104ec5780634821c1bc1461050c5780634b07954a1461052c57600080fd5b806318160ddd1161026657806318160ddd146103dd5780631f040297146103fd57806323b872dd1461041d5780632eb4a7ab1461043d5780632f745c5914610454578063362f04c01461047457600080fd5b806301ffc9a7146102b957806302a57a45146102ee57806306fdde0314610310578063081812fc14610332578063095ea7b31461035f578063150b7a021461037f57600080fd5b366102b457005b600080fd5b3480156102c557600080fd5b506102d96102d4366004613853565b61097e565b60405190151581526020015b60405180910390f35b3480156102fa57600080fd5b5061030e610309366004613870565b61098f565b005b34801561031c57600080fd5b50610325610a19565b6040516102e591906138d9565b34801561033e57600080fd5b5061035261034d366004613870565b610aab565b6040516102e591906138ec565b34801561036b57600080fd5b5061030e61037a366004613917565b610ad2565b34801561038b57600080fd5b506103c461039a366004613989565b7f150b7a023d4804d13e8c85fb27262cb750cf6ba9f9dd3bb30d90f482ceeb4b1f95945050505050565b6040516001600160e01b031990911681526020016102e5565b3480156103e957600080fd5b50610161545b6040519081526020016102e5565b34801561040957600080fd5b5061030e610418366004613ae2565b610bec565b34801561042957600080fd5b5061030e610438366004613bd1565b610db0565b34801561044957600080fd5b506103ef6101925481565b34801561046057600080fd5b506103ef61046f366004613917565b610de2565b34801561048057600080fd5b50610197546103ef565b34801561049657600080fd5b506104aa6104a5366004613c9b565b610e79565b6040516102e59190613db7565b3480156104c357600080fd5b5061030e611369565b3480156104d857600080fd5b5061030e6104e7366004613bd1565b61137b565b3480156104f857600080fd5b5061030e610507366004613870565b611396565b34801561051857600080fd5b5061030e610527366004613e04565b6113c7565b34801561053857600080fd5b5061054c610547366004613870565b61147c565b6040516102e59190613e21565b34801561056557600080fd5b506103ef610574366004613870565b6114e2565b34801561058557600080fd5b50610599610594366004613870565b611577565b6040516102e59796959493929190613e41565b3480156105b857600080fd5b5060975460ff166102d9565b3480156105d057600080fd5b506105e46105df366004613e93565b611669565b6040516102e59190613ee0565b3480156105fd57600080fd5b5061035261060c366004613870565b611867565b34801561061d57600080fd5b5061035261062c366004613870565b61189c565b34801561063d57600080fd5b506103ef61064c366004613f18565b6118c7565b34801561065d57600080fd5b5061030e61194d565b34801561067257600080fd5b506102d9610681366004613f33565b61195f565b34801561069257600080fd5b5061030e6106a1366004613f79565b611a03565b3480156106b257600080fd5b506103ef6106c1366004613870565b61019a6020526000908152604090205481565b3480156106e057600080fd5b506106f46106ef366004613fad565b611a1c565b6040516102e59190613fcf565b34801561070d57600080fd5b5061030e611b1f565b34801561072257600080fd5b5060fb546001600160a01b0316610352565b34801561074057600080fd5b506102d961074f366004614040565b611b2f565b34801561076057600080fd5b50610325611b4b565b34801561077557600080fd5b50610789610784366004614040565b611b5a565b6040516102e5919061405b565b3480156107a257600080fd5b506000196103ef565b3480156107b757600080fd5b5061030e6107c63660046140d3565b611cb4565b3480156107d757600080fd5b50610191546107f09062010000900464ffffffffff1681565b60405164ffffffffff90911681526020016102e5565b6103ef61081436600461410a565b611cbf565b34801561082557600080fd5b5061030e61083436600461417b565b611de8565b34801561084557600080fd5b5061030e610854366004613f79565b611e20565b34801561086557600080fd5b50610325610874366004613870565b611e35565b34801561088557600080fd5b50610196546103ef565b34801561089b57600080fd5b506105e4611f5c565b3480156108b057600080fd5b506102d96108bf3660046141ea565b611fd8565b3480156108d057600080fd5b506103c46108df36600461421d565b7ff23a6e612e1ff4830e658fe43f4e3cb4a5f8170bd5d9e69fb5d7a7fa9e4fdf979695505050505050565b34801561091657600080fd5b5061030e610925366004613f18565b612006565b34801561093657600080fd5b50610191546107f090600160381b900464ffffffffff1681565b34801561095c57600080fd5b506103ef61019b5481565b34801561097357600080fd5b506103ef61019c5481565b60006109898261207c565b92915050565b6109976120a1565b61099f6120fb565b6109a7612144565b6101955461019654604051638c0f463560e01b81526001600160a01b0390921691638c0f4635916109de9160040190815260200190565b600060405180830381600087803b1580156109f857600080fd5b505af1158015610a0c573d6000803e3d6000fd5b5050506101929190915550565b606060658054610a2890614294565b80601f0160208091040260200160405190810160405280929190818152602001828054610a5490614294565b8015610aa15780601f10610a7657610100808354040283529160200191610aa1565b820191906000526020600020905b815481529060010190602001808311610a8457829003601f168201915b5050505050905090565b6000610ab68261219f565b506000908152606960205260409020546001600160a01b031690565b6000610add82611867565b9050806001600160a01b0316836001600160a01b031603610b4f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610b6b5750610b6b8133611fd8565b610bdd5760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610b46565b610be783836121c4565b505050565b600054610100900460ff1615808015610c0c5750600054600160ff909116105b80610c265750303b158015610c26575060005460ff166001145b610c895760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b46565b6000805460ff191660011790558015610cac576000805461ff0019166101001790555b610191805464ffffffffff848116600160381b0264ffffffffff60381b199187166201000002919091166bffffffffffffffffffff00001990921691909117179055610193610cfb878261431c565b50610194610d09868261431c565b50610191805460ff19168a151517905561019580546001600160a01b0319166001600160a01b038616179055610d3f8888612232565b610d47612263565b610d4f612292565b610d576122c1565b610d5f6122c1565b8015610da5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b610dbb335b826122e8565b610dd75760405162461bcd60e51b8152600401610b46906143db565b610be7838383612346565b6000610ded836118c7565b8210610e4f5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610b46565b506001600160a01b0391909116600090815261015f60209081526040808320938352929052205490565b6060610e836120a1565b610e8b612144565b610e93611369565b61019154610100900460ff1615610eec5760405162461bcd60e51b815260206004820152601d60248201527f53657373696f6e2077696e6e65727320616c726561647920666f756e640000006044820152606401610b46565b6000610ef86101615490565b610196549091506000906001600160401b03811115610f1957610f19613a10565b604051908082528060200260200182016040528015610f42578160200160208202803683370190505b50905081600003610f565791506113619050565b60005b610196548110156112b15782156112b1578551811461129f576000878281518110610f8657610f86614428565b602002602001015190506000878381518110610fa457610fa4614428565b6020026020010151905060006101978281548110610fc457610fc4614428565b600091825260208220015489516001600160a01b039091169250899086908110610ff057610ff0614428565b6020026020010151905061101e8c868151811061100f5761100f614428565b6020026020010151838361195f565b6110615760405162461bcd60e51b815260206004820152601460248201527324b73b30b634b21036b2b935b63290383937b7b360611b6044820152606401610b46565b61019554604051632d3e27f760e01b815260048101869052602481018790526001600160a01b0390911690632d3e27f790604401602060405180830381865afa1580156110b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d6919061443e565b6111125760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610b46565b600061111e8886614471565b905060005b868110156111a85760008c828151811061113f5761113f614428565b6020026020010151905085811015611195576000610197828154811061116757611167614428565b6000918252602090912001546001600160a01b03169050611187816118c7565b611191908561449b565b9350505b50806111a0816144ae565b915050611123565b508181146111b5876124a5565b6111be836124a5565b6111c7856124a5565b6040516020016111d9939291906144c7565b604051602081830303815290604052906112065760405162461bcd60e51b8152600401610b4691906138d9565b5082610196878154811061121c5761121c614428565b906000526020600020906005020160040160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508287878151811061126457611264614428565b60200260200101906001600160a01b031690816001600160a01b03168152505061128d836118c7565b6112979089614543565b975050505050505b806112a9816144ae565b915050610f59565b5060005b6101965481101561134c5760008282815181106112d4576112d4614428565b6020026020010151905060006001600160a01b0316816001600160a01b0316146113395761019b8054906000611309836144ae565b909155505061019b5461131c8282612537565b61132783600261449b565b600091825261019d6020526040909120555b5080611344816144ae565b9150506112b5565b50610191805461ff0019166101001790559150505b949350505050565b6113716120a1565b611379612640565b565b610be783838360405180602001604052806000815250611de8565b61139f33610db5565b6113bb5760405162461bcd60e51b8152600401610b46906143db565b6113c48161268c565b50565b61019154610100900460ff166114165760405162461bcd60e51b815260206004820152601460248201527313595d1a1bd9081b9bdd08185b1b1bddc81e595d60621b6044820152606401610b46565b61141e612144565b33600061142a826118c7565b90506000611439600183614543565b90505b60006114488483610de2565b600081815261019d6020526040812054919250036114695761146981611396565b508061147481614556565b91505061143c565b6040805180820190915260008082526020820152600061019783815481106114a6576114a6614428565b60009182526020918290200154604080518082019091526001600160a01b0390911680825292509081016114d9836118c7565b90529392505050565b60006114ee6101615490565b82106115515760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610b46565b610161828154811061156557611565614428565b90600052602060002001549050919050565b610196818154811061158857600080fd5b90600052602060002090600502016000915090508060000180546115ab90614294565b80601f01602080910402602001604051908101604052809291908181526020018280546115d790614294565b80156116245780601f106115f957610100808354040283529160200191611624565b820191906000526020600020905b81548152906001019060200180831161160757829003601f168201915b505050600184015460028501546003860154600490960154949591949093506001600160a01b03808316935060ff600160a01b8404811693600160a81b900416911687565b60606116736120a1565b61167b61275b565b6101915442600160381b90910464ffffffffff16106116dc5760405162461bcd60e51b815260206004820152601a60248201527f53657373696f6e206973206e6f742073746172746564207965740000000000006044820152606401610b46565b60008251116117275760405162461bcd60e51b8152602060048201526017602482015276139bc81d1c9e1b881a185cda195cc81c1c9bdd9a591959604a1b6044820152606401610b46565b600082516001600160401b0381111561174257611742613a10565b60405190808252806020026020018201604052801561176b578160200160208202803683370190505b50905060005b835181101561185f5761019a600085838151811061179157611791614428565b60200260200101518152602001908152602001600020546000146117eb5760405162461bcd60e51b8152602060048201526011602482015270151c9e1b88185b1c9958591e481d5cd959607a1b6044820152606401610b46565b60006117f886600061271d565b90508083838151811061180d5761180d614428565b6020026020010181815250508061019a600087858151811061183157611831614428565b6020026020010151815260200190815260200160002081905550508080611857906144ae565b915050611771565b509392505050565b6000818152606760205260408120546001600160a01b0316806109895760405162461bcd60e51b8152600401610b469061456d565b61019781815481106118ad57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006001600160a01b0382166119315760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610b46565b506001600160a01b031660009081526068602052604090205490565b6119556120a1565b61137960006127ab565b6101925460009081036119a55760405162461bcd60e51b815260206004820152600e60248201526d149bdbdd081b9bdd08199bdd5b9960921b6044820152606401610b46565b61019254604080516001600160a01b038616602082015290810184905261136191869160600160408051601f1981840301815282825280516020918201209083015201604051602081830303815290604052805190602001206127fd565b611a0b6120a1565b610194611a18828261431c565b5050565b60606000611a2a8484614543565b6001600160401b03811115611a4157611a41613a10565b604051908082528060200260200182016040528015611a8657816020015b6040805180820190915260008082526020820152815260200190600190039081611a5f5790505b50905060005b8385101561185f5760006101978681548110611aaa57611aaa614428565b60009182526020918290200154604080518082019091526001600160a01b039091168082529250908101611add836118c7565b815250838381518110611af257611af2614428565b60200260200101819052508180611b08906144ae565b925050508480611b17906144ae565b955050611a8c565b611b276120a1565b611379612813565b6000611b396120a1565b611b4282612850565b5060015b919050565b606060668054610a2890614294565b6040805160e081018252606080825260006020830181905292820183905281018290526080810182905260a0810182905260c08101919091526101968260ff1681548110611baa57611baa614428565b90600052602060002090600502016040518060e0016040529081600082018054611bd390614294565b80601f0160208091040260200160405190810160405280929190818152602001828054611bff90614294565b8015611c4c5780601f10611c2157610100808354040283529160200191611c4c565b820191906000526020600020905b815481529060010190602001808311611c2f57829003601f168201915b5050509183525050600182015460208201526002820154604082015260038201546001600160a01b03808216606084015260ff600160a01b830481166080850152600160a81b909204909116151560a083015260049092015490911660c09091015292915050565b611a18338383612c32565b6000611cc96120a1565b611cd161275b565b6040805160e081018252878152602081018790529081018590526001600160a01b038416606082015260ff83166080820152600060a0820181905260c0820181905261019680546001810182559152815160059091027f828feda00a4b64eb35101b6df8f6c29717b1ea6bae5dd03d3ddada8de0a9e7cb01908190611d56908261431c565b5060208201516001820155604082015160028201556060820151600382018054608085015160a08601511515600160a81b0260ff60a81b1960ff909216600160a01b026001600160a81b03199093166001600160a01b0395861617929092171617905560c09092015160049091018054919092166001600160a01b031991909116179055506101965495945050505050565b611df233836122e8565b611e0e5760405162461bcd60e51b8152600401610b46906143db565b611e1a84848484612cfc565b50505050565b611e286120a1565b610193611a18828261431c565b6060611e408261219f565b600082815261019d602052604081205490606090829003611ef657611eef6101938054611e6c90614294565b80601f0160208091040260200160405190810160405280929190818152602001828054611e9890614294565b8015611ee55780601f10611eba57610100808354040283529160200191611ee5565b820191906000526020600020905b815481529060010190602001808311611ec857829003601f168201915b5050505050612d2f565b9050611f55565b81600103611f0f57611eef6101948054611e6c90614294565b6000611f1c600284614543565b9050611f516101968281548110611f3557611f35614428565b90600052602060002090600502016000018054611e6c90614294565b9150505b9392505050565b61019554604051632c9bf44560e11b81526060916001600160a01b031690635937e88a90611f8e9030906004016138ec565b600060405180830381865afa158015611fab573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611fd3919081019061459f565b905090565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b61200e6120a1565b6001600160a01b0381166120735760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b46565b6113c4816127ab565b60006001600160e01b0319821663780e9d6360e01b1480610989575061098982612d60565b60fb546001600160a01b031633146113795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b46565b60975460ff166113795760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b46565b61019154426201000090910464ffffffffff16106113795760405162461bcd60e51b815260206004820152601860248201527714d95cdcda5bdb881a5cc81b9bdd08195b991959081e595d60421b6044820152606401610b46565b6121a881612db0565b6113c45760405162461bcd60e51b8152600401610b469061456d565b600081815260696020526040902080546001600160a01b0319166001600160a01b03841690811790915581906121f982611867565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600054610100900460ff166122595760405162461bcd60e51b8152600401610b469061462f565b611a188282612dcd565b600054610100900460ff1661228a5760405162461bcd60e51b8152600401610b469061462f565b611379612e0d565b600054610100900460ff166122b95760405162461bcd60e51b8152600401610b469061462f565b611379612e40565b600054610100900460ff166113795760405162461bcd60e51b8152600401610b469061462f565b6000806122f483611867565b9050806001600160a01b0316846001600160a01b0316148061231b575061231b8185611fd8565b806113615750836001600160a01b031661233484610aab565b6001600160a01b031614949350505050565b826001600160a01b031661235982611867565b6001600160a01b03161461237f5760405162461bcd60e51b8152600401610b469061467a565b6001600160a01b0382166123e15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610b46565b6123ee8383836001612e70565b826001600160a01b031661240182611867565b6001600160a01b0316146124275760405162461bcd60e51b8152600401610b469061467a565b600081815260696020908152604080832080546001600160a01b03199081169091556001600160a01b03878116808652606885528386208054600019019055908716808652838620805460010190558686526067909452828520805490921684179091559051849360008051602061488d83398151915291a4505050565b606060006124b283612fd7565b60010190506000816001600160401b038111156124d1576124d1613a10565b6040519080825280601f01601f1916602001820160405280156124fb576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461250557509392505050565b6001600160a01b03821661258d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b46565b61259681612db0565b156125b35760405162461bcd60e51b8152600401610b46906146bf565b6125c1600083836001612e70565b6125ca81612db0565b156125e75760405162461bcd60e51b8152600401610b46906146bf565b6001600160a01b038216600081815260686020908152604080832080546001019055848352606790915280822080546001600160a01b03191684179055518392919060008051602061488d833981519152908290a45050565b6126486120fb565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161268291906138ec565b60405180910390a1565b600061269782611867565b90506126a7816000846001612e70565b6126b082611867565b600083815260696020908152604080832080546001600160a01b03199081169091556001600160a01b03851680855260688452828520805460001901905587855260679093528184208054909116905551929350849260008051602061488d833981519152908390a45050565b61019b80546000918261272f836144ae565b909155505061019b5461274284826130af565b600081815261019d602052604090209290925550919050565b61019154426201000090910464ffffffffff16116113795760405162461bcd60e51b815260206004820152600d60248201526c14d95cdcda5bdb88195b991959609a1b6044820152606401610b46565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008261280a85846130c9565b14949350505050565b61281b61310e565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126753390565b612858612144565b60006101968260ff168154811061287157612871614428565b90600052602060002090600502016040518060e001604052908160008201805461289a90614294565b80601f01602080910402602001604051908101604052809291908181526020018280546128c690614294565b80156129135780601f106128e857610100808354040283529160200191612913565b820191906000526020600020905b8154815290600101906020018083116128f657829003601f168201915b5050509183525050600182015460208201526002820154604082015260038201546001600160a01b03808216606084015260ff600160a01b830481166080850152600160a81b909204909116151560a0830152600490920154821660c09182015282015191925060009116612989575032612990565b5060c08101515b816080015160ff16600003612a3b5760208201516040516000916001600160a01b038416918381818185875af1925050503d80600081146129ed576040519150601f19603f3d011682016040523d82523d6000602084013e6129f2565b606091505b5050905080612a355760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610b46565b50612bec565b816080015160ff16600103612acd57606082015160208301516040516323b872dd60e01b81526001600160a01b038316916323b872dd91612a839130918791906004016146f6565b6020604051808303816000875af1158015612aa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ac6919061443e565b5050612bec565b816080015160ff16600203612b4d5760608201516040808401519051632142170760e11b81526001600160a01b038316916342842e0e91612b159130918791906004016146f6565b600060405180830381600087803b158015612b2f57600080fd5b505af1158015612b43573d6000803e3d6000fd5b5050505050612bec565b816080015160ff16600303612bec57606082015160408084015160208501519151637921219560e11b81523060048201526001600160a01b0385811660248301526044820192909252606481019290925260a06084830152600060a483015282169063f242432a9060c401600060405180830381600087803b158015612bd257600080fd5b505af1158015612be6573d6000803e3d6000fd5b50505050505b60016101968460ff1681548110612c0557612c05614428565b906000526020600020906005020160030160156101000a81548160ff021916908315150217905550505050565b816001600160a01b0316836001600160a01b031603612c8f5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610b46565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612d07848484612346565b612d1384848484613154565b611e1a5760405162461bcd60e51b8152600401610b469061471a565b6060612d3a82613252565b604051602001612d4a919061476c565b6040516020818303038152906040529050919050565b60006001600160e01b031982166380ac58cd60e01b1480612d9157506001600160e01b03198216635b5e139f60e01b145b8061098957506301ffc9a760e01b6001600160e01b0319831614610989565b6000908152606760205260409020546001600160a01b0316151590565b600054610100900460ff16612df45760405162461bcd60e51b8152600401610b469061462f565b6065612e00838261431c565b506066610be7828261431c565b600054610100900460ff16612e345760405162461bcd60e51b8152600401610b469061462f565b6097805460ff19169055565b600054610100900460ff16612e675760405162461bcd60e51b8152600401610b469061462f565b611379336127ab565b612e7c848484846133a4565b6101915460ff1680612e9557506001600160a01b038416155b80612ead575060fb546001600160a01b038581169116145b612ef95760405162461bcd60e51b815260206004820152601a60248201527f5469636b6574206973206e6f74207472616e7366657261626c650000000000006044820152606401610b46565b826001600160a01b0316846001600160a01b03160315611e1a576001600160a01b03841615801590612f335750612f2f846118c7565b6001145b15612f4157612f41846134e6565b6001600160a01b038316612f6457600082815261019d6020526040812055611e1a565b612f6d836118c7565b600003611e1a5761019780546001600160a01b038516600081815261019860205260408120839055600183018455929092527f3ea4d693734e62a1b4642df418cf4aae0e5ba336a2d6024b2d33585611a4e2eb0180546001600160a01b0319169091179055611e1a565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106130165772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613042576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061306057662386f26fc10000830492506010015b6305f5e1008310613078576305f5e100830492506008015b612710831061308c57612710830492506004015b6064831061309e576064830492506002015b600a83106109895760010192915050565b611a188282604051806020016040528060008152506135da565b600081815b845181101561185f576130fa828683815181106130ed576130ed614428565b602002602001015161360d565b915080613106816144ae565b9150506130ce565b60975460ff16156113795760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610b46565b60006001600160a01b0384163b1561324a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906131989033908990889088906004016147b1565b6020604051808303816000875af19250505080156131d3575060408051601f3d908101601f191682019092526131d0918101906147ee565b60015b613230573d808015613201576040519150601f19603f3d011682016040523d82523d6000602084013e613206565b606091505b5080516000036132285760405162461bcd60e51b8152600401610b469061471a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611361565b506001611361565b6060815160000361327157505060408051602081019091526000815290565b600060405180606001604052806040815260200161484d60409139905060006003845160026132a0919061449b565b6132aa919061480b565b6132b590600461481f565b6001600160401b038111156132cc576132cc613a10565b6040519080825280601f01601f1916602001820160405280156132f6576020820181803683370190505b509050600182016020820185865187015b80821015613362576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250613307565b505060038651066001811461337e576002811461339157613399565b603d6001830353603d6002830353613399565b603d60018303535b509195945050505050565b6133b084848484613639565b600181111561341f5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610b46565b816001600160a01b03851661347d57613478816101618054600083815261016260205260408120829055600182018355919091527fafbb1c043347995df017ce3291b765e028ad5f784d2aa00c3f5e073760a4de8b0155565b6134a0565b836001600160a01b0316856001600160a01b0316146134a0576134a085826136a0565b6001600160a01b0384166134bc576134b781613742565b6134df565b846001600160a01b0316846001600160a01b0316146134df576134df84826137f7565b5050505050565b610197546000906134f990600190614543565b6001600160a01b03831660009081526101986020526040812054610197805493945090928490811061352d5761352d614428565b60009182526020909120015461019780546001600160a01b03909216925082918490811061355d5761355d614428565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790558383168252610198905260408082208590559186168152908120556101978054806135b2576135b2614836565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b6135e48383612537565b6135f16000848484613154565b610be75760405162461bcd60e51b8152600401610b469061471a565b6000818310613629576000828152602084905260409020611f55565b5060009182526020526040902090565b60975460ff1615611e1a5760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610b46565b600060016136ad846118c7565b6136b79190614543565b6000838152610160602052604090205490915080821461370d576001600160a01b038416600090815261015f60209081526040808320858452825280832054848452818420819055835261016090915290208190555b506000918252610160602090815260408084208490556001600160a01b03909416835261015f81528383209183525290812055565b6101615460009061375590600190614543565b60008381526101626020526040812054610161805493945090928490811061377f5761377f614428565b906000526020600020015490508061016183815481106137a1576137a1614428565b600091825260208083209091019290925582815261016290915260408082208490558582528120556101618054806137db576137db614836565b6001900381819060005260206000200160009055905550505050565b6000613802836118c7565b6001600160a01b03909316600090815261015f6020908152604080832086845282528083208590559382526101609052919091209190915550565b6001600160e01b0319811681146113c457600080fd5b60006020828403121561386557600080fd5b8135611f558161383d565b60006020828403121561388257600080fd5b5035919050565b60005b838110156138a457818101518382015260200161388c565b50506000910152565b600081518084526138c5816020860160208601613889565b601f01601f19169290920160200192915050565b602081526000611f5560208301846138ad565b6001600160a01b0391909116815260200190565b80356001600160a01b0381168114611b4657600080fd5b6000806040838503121561392a57600080fd5b61393383613900565b946020939093013593505050565b60008083601f84011261395357600080fd5b5081356001600160401b0381111561396a57600080fd5b60208301915083602082850101111561398257600080fd5b9250929050565b6000806000806000608086880312156139a157600080fd5b6139aa86613900565b94506139b860208701613900565b93506040860135925060608601356001600160401b038111156139da57600080fd5b6139e688828901613941565b969995985093965092949392505050565b80151581146113c457600080fd5b8035611b46816139f7565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613a4e57613a4e613a10565b604052919050565b60006001600160401b03831115613a6f57613a6f613a10565b613a82601f8401601f1916602001613a26565b9050828152838383011115613a9657600080fd5b828260208301376000602084830101529392505050565b600082601f830112613abe57600080fd5b611f5583833560208501613a56565b803564ffffffffff81168114611b4657600080fd5b600080600080600080600080610100898b031215613aff57600080fd5b613b0889613a05565b975060208901356001600160401b0380821115613b2457600080fd5b613b308c838d01613aad565b985060408b0135915080821115613b4657600080fd5b613b528c838d01613aad565b975060608b0135915080821115613b6857600080fd5b613b748c838d01613aad565b965060808b0135915080821115613b8a57600080fd5b50613b978b828c01613aad565b945050613ba660a08a01613900565b9250613bb460c08a01613acd565b9150613bc260e08a01613acd565b90509295985092959890939650565b600080600060608486031215613be657600080fd5b613bef84613900565b9250613bfd60208501613900565b9150604084013590509250925092565b60006001600160401b03821115613c2657613c26613a10565b5060051b60200190565b600082601f830112613c4157600080fd5b81356020613c56613c5183613c0d565b613a26565b82815260059290921b84018101918181019086841115613c7557600080fd5b8286015b84811015613c905780358352918301918301613c79565b509695505050505050565b60008060008060808587031215613cb157600080fd5b84356001600160401b0380821115613cc857600080fd5b818701915087601f830112613cdc57600080fd5b81356020613cec613c5183613c0d565b82815260059290921b8401810191818101908b841115613d0b57600080fd5b8286015b84811015613d4357803586811115613d275760008081fd5b613d358e86838b0101613c30565b845250918301918301613d0f565b5098505088013592505080821115613d5a57600080fd5b613d6688838901613c30565b94506040870135915080821115613d7c57600080fd5b613d8888838901613c30565b93506060870135915080821115613d9e57600080fd5b50613dab87828801613c30565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b81811015613df85783516001600160a01b031683529284019291840191600101613dd3565b50909695505050505050565b600060208284031215613e1657600080fd5b8135611f55816139f7565b81516001600160a01b031681526020808301519082015260408101610989565b60e081526000613e5460e083018a6138ad565b60208301989098525060408101959095526001600160a01b03938416606086015260ff929092166080850152151560a08401521660c090910152919050565b60008060408385031215613ea657600080fd5b613eaf83613900565b915060208301356001600160401b03811115613eca57600080fd5b613ed685828601613c30565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b81811015613df857835183529284019291840191600101613efc565b600060208284031215613f2a57600080fd5b611f5582613900565b600080600060608486031215613f4857600080fd5b83356001600160401b03811115613f5e57600080fd5b613f6a86828701613c30565b935050613bfd60208501613900565b600060208284031215613f8b57600080fd5b81356001600160401b03811115613fa157600080fd5b61136184828501613aad565b60008060408385031215613fc057600080fd5b50508035926020909101359150565b602080825282518282018190526000919060409081850190868401855b828110156140225761401284835180516001600160a01b03168252602090810151910152565b9284019290850190600101613fec565b5091979650505050505050565b803560ff81168114611b4657600080fd5b60006020828403121561405257600080fd5b611f558261402f565b602081526000825160e060208401526140786101008401826138ad565b90506020840151604084015260408401516060840152606084015160018060a01b03808216608086015260ff60808701511660a086015260a0860151151560c08601528060c08701511660e086015250508091505092915050565b600080604083850312156140e657600080fd5b6140ef83613900565b915060208301356140ff816139f7565b809150509250929050565b600080600080600060a0868803121561412257600080fd5b85356001600160401b0381111561413857600080fd5b61414488828901613aad565b955050602086013593506040860135925061416160608701613900565b915061416f6080870161402f565b90509295509295909350565b6000806000806080858703121561419157600080fd5b61419a85613900565b93506141a860208601613900565b92506040850135915060608501356001600160401b038111156141ca57600080fd5b8501601f810187136141db57600080fd5b613dab87823560208401613a56565b600080604083850312156141fd57600080fd5b61420683613900565b915061421460208401613900565b90509250929050565b60008060008060008060a0878903121561423657600080fd5b61423f87613900565b955061424d60208801613900565b9450604087013593506060870135925060808701356001600160401b0381111561427657600080fd5b61428289828a01613941565b979a9699509497509295939492505050565b600181811c908216806142a857607f821691505b6020821081036142c857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610be757600081815260208120601f850160051c810160208610156142f55750805b601f850160051c820191505b8181101561431457828155600101614301565b505050505050565b81516001600160401b0381111561433557614335613a10565b614349816143438454614294565b846142ce565b602080601f83116001811461437e57600084156143665750858301515b600019600386901b1c1916600185901b178555614314565b600085815260208120601f198616915b828110156143ad5788860151825594840194600190910190840161438e565b50858210156143cb5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561445057600080fd5b8151611f55816139f7565b634e487b7160e01b600052601260045260246000fd5b6000826144805761448061445b565b500690565b634e487b7160e01b600052601160045260246000fd5b8082018082111561098957610989614485565b6000600182016144c0576144c0614485565b5060010190565b7502bb4b73732b91034b73232bc1036b4b9b6b0ba31b4160551b8152600084516144f8816016850160208901613889565b8083019050600160fd1b806016830152855161451b816017850160208a01613889565b60179201918201528351614536816018840160208801613889565b0160180195945050505050565b8181038181111561098957610989614485565b60008161456557614565614485565b506000190190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b600060208083850312156145b257600080fd5b82516001600160401b038111156145c857600080fd5b8301601f810185136145d957600080fd5b80516145e7613c5182613c0d565b81815260059190911b8201830190838101908783111561460657600080fd5b928401925b828410156146245783518252928401929084019061460b565b979650505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516147a481601d850160208701613889565b91909101601d0192915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906147e4908301846138ad565b9695505050505050565b60006020828403121561480057600080fd5b8151611f558161383d565b60008261481a5761481a61445b565b500490565b808202811582820484141761098957610989614485565b634e487b7160e01b600052603160045260246000fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202c44493d497081ebf475705a89735be01466de1ecbbb27a552c5b9b04c34fc2764736f6c63430008130033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.