ETH Price: $2,338.59 (-0.42%)

Contract

0xD7E5D69893699CdD76417C9B0947A1043a3C4b58
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Initialize169799372023-04-05 3:27:23532 days ago1680665243IN
0xD7E5D698...43a3C4b58
0 ETH0.0086962146.68380853
0x60a06040169799302023-04-05 3:25:59532 days ago1680665159IN
 Create: TablelandRigPilots
0 ETH0.1289452847.84773154

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TablelandRigPilots

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 21 : TablelandRigPilots.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.10 <0.9.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165CheckerUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@tableland/evm/contracts/utils/SQLHelpers.sol";
import "@tableland/evm/contracts/utils/TablelandDeployments.sol";
import "./ITablelandRigPilots.sol";

/**
 * @dev Implementation of {ITablelandRigPilots}.
 */
contract TablelandRigPilots is
    ITablelandRigPilots,
    OwnableUpgradeable,
    UUPSUpgradeable
{
    using ERC165CheckerUpgradeable for address;

    // Table prefix for the Rigs pilot sessions table.
    string private constant _PILOT_SESSIONS_PREFIX = "pilot_sessions";

    // Number of blocks that a Rig must train before piloting.
    uint256 private constant _PILOT_TRAINING_DURATION = 172800;

    // Mask of the lower 64 bits of a pilot; the flight start time
    uint256 private constant _BITMASK_START_TIME = (1 << 64) - 1;

    // Mask of all pilot bits, except the start time
    uint256 private constant _BITMASK_START_TIME_COMPLEMENT =
        _BITMASK_START_TIME ^ type(uint256).max;

    // Bit position of the pilot ID
    uint256 private constant _BITPOS_PILOT_ID = 64;

    // Bit position of the pilot contract
    uint256 private constant _BITPOS_PILOT_ADDR = 96;

    // Address of parent contract
    address private _parent;

    // Table ID for the Rigs pilot sessions table.
    uint256 private _pilotSessionsTableId;

    // Tracks the Rig `tokenId` to its current pilot, represented as a packed `uint256`.
    //
    // Bits layout:
    // - [0..63]    `startTime` - starting block number of pilot's flight time
    // - [64..95]   `pilotId` - ERC-721 token ID of the pilot at `pilotAddr`
    // - [96..255]  `pilotAddr` - address of the ERC-721 contract for the pilot
    mapping(uint16 => uint256) private _pilots;

    // Tracks the packed "pilot data" (pilot contract and pilot ID) to the Rig `tokenId`.
    // Used to help check if a custom pilot is in use.
    mapping(uint192 => uint16) private _pilotIndex;

    function initialize(address parent_) public initializer {
        __Ownable_init();
        __UUPSUpgradeable_init();

        _parent = parent_;
        _pilotSessionsTableId = TablelandDeployments.get().createTable(
            address(this),
            SQLHelpers.toCreateFromSchema(
                "id integer primary key,"
                "rig_id integer not null,"
                "owner text not null,"
                "pilot_contract text,"
                "pilot_id integer,"
                "start_time integer not null,"
                "end_time integer",
                _PILOT_SESSIONS_PREFIX
            )
        );
    }

    /**
     * @dev Throws if called by any account other than the parent.
     */
    modifier onlyParent() {
        _checkParent();
        _;
    }

    /**
     * @dev Throws if the sender is not the parent.
     */
    function _checkParent() private view {
        require(parent() == _msgSender(), "Pilots: caller is not the parent");
    }

    // =============================
    //      ITABLELANDRIGPILOTS
    // =============================

    /**
     * @dev See {ITablelandRigPilots-parent}.
     */
    function parent() public view returns (address) {
        return _parent;
    }

    /**
     * @dev See {ITablelandRigPilots-pilotSessionsTable}.
     */
    function pilotSessionsTable() external view returns (string memory) {
        return
            SQLHelpers.toNameFromId(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId
            );
    }

    /**
     * @dev See {ITablelandRigPilots-pilotInfo}.
     */
    function pilotInfo(
        uint256 tokenId
    ) external view returns (PilotInfo memory) {
        return
            PilotInfo(
                _pilotStatus(tokenId),
                pilotStartTime(tokenId),
                _canPilot(tokenId),
                address(
                    uint160(_pilots[uint16(tokenId)] >> _BITPOS_PILOT_ADDR)
                ),
                uint256(uint32(_pilots[uint16(tokenId)] >> _BITPOS_PILOT_ID))
            );
    }

    /**
     * @dev See {ITablelandRigPilots-pilotStartTime}.
     */
    function pilotStartTime(uint256 tokenId) public view returns (uint64) {
        return uint64(_pilots[uint16(tokenId)]);
    }

    /**
     * @dev Returns a pilot's data (packed `uint32` pilot ID and `uint160` pilot contract).
     *
     * tokenId - the unique Rig token identifier
     */
    function _pilotData(uint256 tokenId) private view returns (uint192) {
        return uint192(_pilots[uint16(tokenId)] >> _BITPOS_PILOT_ID);
    }

    /**
     * @dev Sets a pilot's start time.
     *
     * tokenId - the unique Rig token identifier
     * startTime - the starting block number when putting a Rig into flight
     */
    function _setStartTime(uint16 tokenId, uint64 startTime) private {
        // Cast `startTime` with assembly to avoid redundant masking
        uint256 startTimeCasted;
        assembly {
            startTimeCasted := startTime
        }

        // Set the pilot, using the complement to mask all bits, except the start time
        // If the provided start time is zero, the mask already sets it to zero
        uint256 pilot = _pilots[tokenId];
        _pilots[tokenId] = startTimeCasted == 0
            ? pilot & _BITMASK_START_TIME_COMPLEMENT
            : (pilot & _BITMASK_START_TIME_COMPLEMENT) | startTimeCasted;
    }

    /**
     * @dev Sets the "pilot data" (both the pilot ID and pilot contract) for a pilot.
     *
     * tokenId - the unique Rig token identifier
     * pilotAddr - ERC-721 contract address of a desired Rig's pilot
     * pilotId - the unique token identifier at the target `pilotAddr`
     */
    function _setPilotData(
        uint16 tokenId,
        uint160 pilotAddr,
        uint32 pilotId
    ) private {
        // Cast "pilot data" (pilot contract and pilot ID) with assembly to avoid redundant masking
        uint256 pilot = _pilots[tokenId];
        uint256 pilotAddrCasted;
        uint256 pilotIdCasted;
        assembly {
            pilotAddrCasted := pilotAddr
            pilotIdCasted := pilotId
        }

        // Set the pilot by first masking the start time
        pilot =
            (pilot & _BITMASK_START_TIME) |
            (pilotIdCasted << _BITPOS_PILOT_ID) |
            (pilotAddrCasted << _BITPOS_PILOT_ADDR);
        _pilots[tokenId] = pilot;
    }

    /**
     * @dev Returns the current Garage status of a Rig.
     *
     * tokenId - the unique Rig token identifier
     */
    function _pilotStatus(uint256 tokenId) private view returns (GarageStatus) {
        // The `park` logic sets "pilot data" (pilot ID and pilot contract) to `0` if both of these are true:
        //   - Pilot data is currently `1` (contract is zero and trainer pilot is in use, `1`)
        //   - Rig has not been training for long enough
        // i.e., `park` results in a status of `UNTRAINED` or `PARKED`
        // Invariant: pilot data cannot be `0` if `startTime` is > `0`
        return
            pilotStartTime(tokenId) == 0
                ? (
                    _pilotData(tokenId) == 0
                        ? GarageStatus.UNTRAINED
                        : GarageStatus.PARKED
                )
                : (
                    _pilotData(tokenId) == 1
                        ? GarageStatus.TRAINING
                        : GarageStatus.PILOTED
                );
    }

    /**
     * @dev Returns whether or not a Rig can be piloted.
     *
     * tokenId - the unique Rig token identifier
     */
    function _canPilot(uint256 tokenId) private view returns (bool) {
        // Cannot switch real pilots mid-flight, but can go from trainer -> real pilot
        // There are two ways to pilot:
        //   1. In a `PARKED` status
        //   2. In a `TRAINING` status for long enough (30 days; 172800 blocks)
        GarageStatus status = _pilotStatus(tokenId);
        return
            status == GarageStatus.PARKED ||
            (status == GarageStatus.TRAINING &&
                block.number >=
                pilotStartTime(tokenId) + _PILOT_TRAINING_DURATION);
    }

    /**
     * @dev See {ITablelandRigPilots-trainRig}.
     */
    function trainRig(address sender, uint256 tokenId) external onlyParent {
        // Validate the Rig is untrained
        if (_pilotStatus(tokenId) != GarageStatus.UNTRAINED)
            revert InvalidPilotStatus();

        // Start training
        _setStartTime(uint16(tokenId), uint64(block.number));

        // Assign a trainer pilot to the Rig in `_pilots`
        // The "pilot data" is pilot contract `0` and pilot ID `1`
        _setPilotData(uint16(tokenId), 0, 1);

        // Insert the Rig training session into the Tableland pilot sessions table
        TablelandDeployments.get().runSQL(
            address(this),
            _pilotSessionsTableId,
            SQLHelpers.toInsert(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId,
                "rig_id,owner,start_time",
                string.concat(
                    StringsUpgradeable.toString(uint16(tokenId)),
                    ",",
                    SQLHelpers.quote(StringsUpgradeable.toHexString(sender)),
                    ",",
                    StringsUpgradeable.toString(uint64(block.number))
                )
            )
        );

        emit Training(tokenId);
    }

    /**
     * @dev See {ITablelandRigPilots-pilotRig}.
     */
    function pilotRig(address sender, uint256 tokenId) external onlyParent {
        // Validate the Rig can be piloted with a trainer pilot. Note that
        // `_canPilot` allows for in-flight piloting once trained *and* in
        // `TRAINING` status, but this only allows for piloting a with trainer
        // if `PARKED`.
        if (_pilotStatus(tokenId) != GarageStatus.PARKED)
            revert InvalidPilotStatus();

        // Assign a trainer pilot to the Rig in `_pilots`. The pilot contract is
        // `0` and pilot ID `2`—this is needed to differentiate from a
        // `TRAINING` Rig's pilot, which has a pilot ID of `1`.
        _setPilotData(uint16(tokenId), 0, 2);

        // Set the start time for the new pilot session
        _setStartTime(uint16(tokenId), uint64(block.number));

        // Insert the trainer pilot session into the Tableland pilot sessions table
        TablelandDeployments.get().runSQL(
            address(this),
            _pilotSessionsTableId,
            SQLHelpers.toInsert(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId,
                "rig_id,owner,start_time",
                string.concat(
                    StringsUpgradeable.toString(uint16(tokenId)),
                    ",",
                    SQLHelpers.quote(StringsUpgradeable.toHexString(sender)),
                    ",",
                    StringsUpgradeable.toString(uint64(block.number))
                )
            )
        );

        emit Piloted(tokenId, address(0), 2);
    }

    /**
     * @dev See {ITablelandRigPilots-pilotRig}.
     */
    function pilotRig(
        address sender,
        uint256 tokenId,
        address pilotAddr,
        uint256 pilotId
    ) external onlyParent {
        // Verify the `pilotId` fits into a `uint32` (required for packing)
        if (pilotId > type(uint32).max)
            revert InvalidCustomPilot("pilot id too big");

        // Check if `pilotAddr` is an ERC-721; cannot be the Rigs contract
        if (
            pilotAddr == parent() ||
            !pilotAddr.supportsInterface(type(IERC721Upgradeable).interfaceId)
        ) revert InvalidCustomPilot("pilot contract not supported");

        // Check ownership of `pilotId` at target `pilotAddr`
        if (IERC721Upgradeable(pilotAddr).ownerOf(pilotId) != sender)
            revert InvalidCustomPilot("unauthorized");

        // Validate the Rig can be piloted
        if (!_canPilot(tokenId)) revert InvalidPilotStatus();

        // Initialize the packed "pilot data" (pilot ID `uint32` with a pilot
        // contract `uint160`, shifted 32 bits)
        uint192 pilotData = (uint192(pilotId) |
            (uint192(uint160(pilotAddr)) << 32));

        // Verify if a pilot is already in use, by checking:
        // 1. Has the custom pilot been used before
        // 2. Was the pilot most recently used by a *different* Rig
        // 3. Is the other Rig in-flight (not `PARKED`)
        // If a different, in-flight Rig is using this pilot, park the other Rig
        if (
            _pilotIndex[pilotData] != 0 &&
            _pilotIndex[pilotData] != tokenId &&
            _pilotStatus(_pilotIndex[pilotData]) != GarageStatus.PARKED
        ) parkRig(_pilotIndex[pilotData], false);

        // If the Rig is training, end its training session (no parking
        // required) to then open a new pilot session. Pilot has completed
        // training at this point (training validation is checked above)
        if (_pilotStatus(tokenId) == GarageStatus.TRAINING) {
            // Update the pilot's existing training session with its `end_time`
            string memory setters = string.concat(
                "end_time=",
                StringsUpgradeable.toString(uint64(block.number))
            );
            // Only update the row with the matching `rig_id` and `start_time`
            string memory filters = string.concat(
                "rig_id=",
                StringsUpgradeable.toString(uint16(tokenId)),
                " and ",
                "start_time=",
                StringsUpgradeable.toString(pilotStartTime(tokenId))
            );
            TablelandDeployments.get().runSQL(
                address(this),
                _pilotSessionsTableId,
                SQLHelpers.toUpdate(
                    _PILOT_SESSIONS_PREFIX,
                    _pilotSessionsTableId,
                    setters,
                    filters
                )
            );
        }
        // The Rig is either `PARKED` or setting its first pilot while in a `TRAINED` status
        // Set the start time for the new pilot session
        _setStartTime(uint16(tokenId), uint64(block.number));

        // Insert the pilot into the Tableland pilot sessions table
        TablelandDeployments.get().runSQL(
            address(this),
            _pilotSessionsTableId,
            SQLHelpers.toInsert(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId,
                "rig_id,owner,pilot_contract,pilot_id,start_time",
                string.concat(
                    StringsUpgradeable.toString(uint16(tokenId)),
                    ",",
                    SQLHelpers.quote(StringsUpgradeable.toHexString(sender)),
                    ",",
                    SQLHelpers.quote(Strings.toHexString(pilotAddr)),
                    ",",
                    StringsUpgradeable.toString(uint32(pilotId)),
                    ",",
                    StringsUpgradeable.toString(uint64(block.number))
                )
            )
        );

        // Update the pilot data and index
        _setPilotData(uint16(tokenId), uint160(pilotAddr), uint32(pilotId));
        _pilotIndex[pilotData] = uint16(tokenId);

        emit Piloted(tokenId, pilotAddr, pilotId);
    }

    /**
     * @dev See {ITablelandRigPilots-parkRig}.
     */
    function parkRig(uint256 tokenId, bool force) public onlyParent {
        // Ensure Rig is currently in-flight
        GarageStatus status = _pilotStatus(tokenId);
        if (
            !(status == GarageStatus.TRAINING || status == GarageStatus.PILOTED)
        ) revert InvalidPilotStatus();
        // Session update type is dependent on training completion status
        // Use `setters` for setting SQL update values, and `startTime` is used for checking training completion status
        string memory setters;
        uint64 startTime = pilotStartTime(tokenId);
        bool trainingIncomplete = status == GarageStatus.TRAINING &&
            !(block.number >= startTime + _PILOT_TRAINING_DURATION);
        bool forceParkedWhileTraining = status == GarageStatus.TRAINING &&
            force;
        // Pilot training is incomplete; reset the training pilot such that the Rig must train again
        if (trainingIncomplete || forceParkedWhileTraining)
            _setPilotData(uint16(tokenId), 0, 0);
        // If the pilot is untrained or being force parked, there are zero flight time rewards
        if (trainingIncomplete || force) {
            // Update the row in pilot sessions table with its `end_time` equal to the `start_time`
            setters = string.concat(
                "end_time=",
                StringsUpgradeable.toString(startTime)
            );
        } else {
            // Training is complete, and the Rig is being parked without "malicious" force park origins
            // Update the row in the pilot sessions table with its `end_time` to accrue flight time rewards
            setters = string.concat(
                "end_time=",
                StringsUpgradeable.toString(uint64(block.number))
            );
        }

        // Only update the row with the matching `rig_id` and `start_time`
        string memory filters = string.concat(
            "rig_id=",
            StringsUpgradeable.toString(uint16(tokenId)),
            " and ",
            "start_time=",
            StringsUpgradeable.toString(startTime)
        );

        // Set the `startTime` to `0` to indicate the Rig is now parked
        _setStartTime(uint16(tokenId), 0);

        // Update the pilot information in the Tableland pilot sessions table
        TablelandDeployments.get().runSQL(
            address(this),
            _pilotSessionsTableId,
            SQLHelpers.toUpdate(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId,
                setters,
                filters
            )
        );

        emit Parked(tokenId);
    }

    /**
     * @dev See {ITablelandRigPilots-updateSessionOwner}.
     */
    function updateSessionOwner(
        uint256 tokenId,
        address newOwner
    ) external onlyParent {
        // Update the row in pilot sessions table with its new `owner`
        uint64 startTime = pilotStartTime(tokenId);
        string memory setters = string.concat(
            "owner=",
            SQLHelpers.quote(StringsUpgradeable.toHexString(newOwner))
        );
        // Only update the row with the matching `rig_id` and `start_time`
        string memory filters = string.concat(
            "rig_id=",
            StringsUpgradeable.toString(uint16(tokenId)),
            " and ",
            "start_time=",
            StringsUpgradeable.toString(startTime)
        );
        // Update the pilot information in the Tableland pilot sessions table
        TablelandDeployments.get().runSQL(
            address(this),
            _pilotSessionsTableId,
            SQLHelpers.toUpdate(
                _PILOT_SESSIONS_PREFIX,
                _pilotSessionsTableId,
                setters,
                filters
            )
        );
    }

    /**
     * @dev Required to create and receive an ERC-721 Tableland TABLE token for pilot sessions.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes calldata
    ) public pure returns (bytes4) {
        return 0x150b7a02;
    }

    // =============================
    //       UUPSUpgradeable
    // =============================

    /**
     * @dev See {UUPSUpgradeable-_authorizeUpgrade}.
     */
    function _authorizeUpgrade(address) internal view override onlyOwner {} // solhint-disable no-empty-blocks
}

File 2 of 21 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 3 of 21 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 4 of 21 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 5 of 21 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @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) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @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;
}

File 6 of 21 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

File 7 of 21 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate that the this implementation remains valid after an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 8 of 21 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 9 of 21 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 10 of 21 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 11 of 21 : ERC165CheckerUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.2) (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165CheckerUpgradeable {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface,
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            _supportsERC165Interface(account, type(IERC165Upgradeable).interfaceId) &&
            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in _interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!_supportsERC165Interface(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
        // prepare call
        bytes memory encodedParams = abi.encodeWithSelector(IERC165Upgradeable.supportsInterface.selector, interfaceId);

        // perform static call
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly {
            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0x00)
        }

        return success && returnSize >= 0x20 && returnValue > 0;
    }
}

File 12 of 21 : IERC165Upgradeable.sol
// 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);
}

File 13 of 21 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 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. It 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)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 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) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}

File 14 of 21 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

File 15 of 21 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 16 of 21 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 17 of 21 : ITablelandController.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
 * @dev Interface of a TablelandController compliant contract.
 *
 * This interface can be implemented to enabled advanced access control for a table.
 * Call {ITablelandTables-setController} with the address of your implementation.
 *
 * See {test/TestTablelandController} for an example of token-gating table write-access.
 */
interface ITablelandController {
    /**
     * @dev Object defining how a table can be accessed.
     */
    struct Policy {
        // Whether or not the table should allow SQL INSERT statements.
        bool allowInsert;
        // Whether or not the table should allow SQL UPDATE statements.
        bool allowUpdate;
        // Whether or not the table should allow SQL DELETE statements.
        bool allowDelete;
        // A conditional clause used with SQL UPDATE and DELETE statements.
        // For example, a value of "foo > 0" will concatenate all SQL UPDATE
        // and/or DELETE statements with "WHERE foo > 0".
        // This can be useful for limiting how a table can be modified.
        // Use {Policies-joinClauses} to include more than one condition.
        string whereClause;
        // A conditional clause used with SQL INSERT statements.
        // For example, a value of "foo > 0" will concatenate all SQL INSERT
        // statements with a check on the incoming data, i.e., "CHECK (foo > 0)".
        // This can be useful for limiting how table data ban be added.
        // Use {Policies-joinClauses} to include more than one condition.
        string withCheck;
        // A list of SQL column names that can be updated.
        string[] updatableColumns;
    }

    /**
     * @dev Returns a {Policy} struct defining how a table can be accessed by `caller`.
     */
    function getPolicy(address caller) external payable returns (Policy memory);
}

File 18 of 21 : ITablelandTables.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "./ITablelandController.sol";

/**
 * @dev Interface of a TablelandTables compliant contract.
 */
interface ITablelandTables {
    /**
     * The caller is not authorized.
     */
    error Unauthorized();

    /**
     * RunSQL was called with a query length greater than maximum allowed.
     */
    error MaxQuerySizeExceeded(uint256 querySize, uint256 maxQuerySize);

    /**
     * @dev Emitted when `owner` creates a new table.
     *
     * owner - the to-be owner of the table
     * tableId - the table id of the new table
     * statement - the SQL statement used to create the table
     */
    event CreateTable(address owner, uint256 tableId, string statement);

    /**
     * @dev Emitted when a table is transferred from `from` to `to`.
     *
     * Not emmitted when a table is created.
     * Also emitted after a table has been burned.
     *
     * from - the address that transfered the table
     * to - the address that received the table
     * tableId - the table id that was transferred
     */
    event TransferTable(address from, address to, uint256 tableId);

    /**
     * @dev Emitted when `caller` runs a SQL statement.
     *
     * caller - the address that is running the SQL statement
     * isOwner - whether or not the caller is the table owner
     * tableId - the id of the target table
     * statement - the SQL statement to run
     * policy - an object describing how `caller` can interact with the table (see {ITablelandController.Policy})
     */
    event RunSQL(
        address caller,
        bool isOwner,
        uint256 tableId,
        string statement,
        ITablelandController.Policy policy
    );

    /**
     * @dev Emitted when a table's controller is set.
     *
     * tableId - the id of the target table
     * controller - the address of the controller (EOA or contract)
     */
    event SetController(uint256 tableId, address controller);

    /**
     * @dev Creates a new table owned by `owner` using `statement` and returns its `tableId`.
     *
     * owner - the to-be owner of the new table
     * statement - the SQL statement used to create the table
     *
     * Requirements:
     *
     * - contract must be unpaused
     */
    function createTable(
        address owner,
        string memory statement
    ) external payable returns (uint256);

    /**
     * @dev Runs a SQL statement for `caller` using `statement`.
     *
     * caller - the address that is running the SQL statement
     * tableId - the id of the target table
     * statement - the SQL statement to run
     *
     * Requirements:
     *
     * - contract must be unpaused
     * - `msg.sender` must be `caller` or contract owner
     * - `tableId` must exist
     * - `caller` must be authorized by the table controller
     * - `statement` must be less than or equal to 35000 bytes
     */
    function runSQL(
        address caller,
        uint256 tableId,
        string memory statement
    ) external payable;

    /**
     * @dev Sets the controller for a table. Controller can be an EOA or contract address.
     *
     * When a table is created, it's controller is set to the zero address, which means that the
     * contract will not enforce write access control. In this situation, validators will not accept
     * transactions from non-owners unless explicitly granted access with "GRANT" SQL statements.
     *
     * When a controller address is set for a table, validators assume write access control is
     * handled at the contract level, and will accept all transactions.
     *
     * You can unset a controller address for a table by setting it back to the zero address.
     * This will cause validators to revert back to honoring owner and GRANT bases write access control.
     *
     * caller - the address that is setting the controller
     * tableId - the id of the target table
     * controller - the address of the controller (EOA or contract)
     *
     * Requirements:
     *
     * - contract must be unpaused
     * - `msg.sender` must be `caller` or contract owner and owner of `tableId`
     * - `tableId` must exist
     * - `tableId` controller must not be locked
     */
    function setController(
        address caller,
        uint256 tableId,
        address controller
    ) external;

    /**
     * @dev Returns the controller for a table.
     *
     * tableId - the id of the target table
     */
    function getController(uint256 tableId) external returns (address);

    /**
     * @dev Locks the controller for a table _forever_. Controller can be an EOA or contract address.
     *
     * Although not very useful, it is possible to lock a table controller that is set to the zero address.
     *
     * caller - the address that is locking the controller
     * tableId - the id of the target table
     *
     * Requirements:
     *
     * - contract must be unpaused
     * - `msg.sender` must be `caller` or contract owner and owner of `tableId`
     * - `tableId` must exist
     * - `tableId` controller must not be locked
     */
    function lockController(address caller, uint256 tableId) external;

    /**
     * @dev Sets the contract base URI.
     *
     * baseURI - the new base URI
     *
     * Requirements:
     *
     * - `msg.sender` must be contract owner
     */
    function setBaseURI(string memory baseURI) external;

    /**
     * @dev Pauses the contract.
     *
     * Requirements:
     *
     * - `msg.sender` must be contract owner
     * - contract must be unpaused
     */
    function pause() external;

    /**
     * @dev Unpauses the contract.
     *
     * Requirements:
     *
     * - `msg.sender` must be contract owner
     * - contract must be paused
     */
    function unpause() external;
}

File 19 of 21 : SQLHelpers.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/Strings.sol";

/**
 * @dev Library of helpers for generating SQL statements from common parameters.
 */
library SQLHelpers {
    /**
     * @dev Generates a properly formatted table name from a prefix and table id.
     *
     * prefix - the user generated table prefix as a string
     * tableId - the Tableland generated tableId as a uint256
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toNameFromId(
        string memory prefix,
        uint256 tableId
    ) internal view returns (string memory) {
        return
            string(
                abi.encodePacked(
                    prefix,
                    "_",
                    Strings.toString(block.chainid),
                    "_",
                    Strings.toString(tableId)
                )
            );
    }

    /**
     * @dev Generates a CREATE statement based on a desired schema and table prefix.
     *
     * schema - a comma seperated string indicating the desired prefix. Example: "int id, text name"
     * prefix - the user generated table prefix as a string
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toCreateFromSchema(
        string memory schema,
        string memory prefix
    ) internal view returns (string memory) {
        return
            string(
                abi.encodePacked(
                    "CREATE TABLE ",
                    prefix,
                    "_",
                    Strings.toString(block.chainid),
                    "(",
                    schema,
                    ")"
                )
            );
    }

    /**
     * @dev Generates an INSERT statement based on table prefix, tableId, columns, and values.
     *
     * prefix - the user generated table prefix as a string.
     * tableId - the Tableland generated tableId as a uint256.
     * columns - a string encoded ordered list of columns that will be updated. Example: "name, age".
     * values - a string encoded ordered list of values that will be inserted wrapped in parentheses. Example: "'jerry', 24". Values order must match column order.
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toInsert(
        string memory prefix,
        uint256 tableId,
        string memory columns,
        string memory values
    ) internal view returns (string memory) {
        string memory name = toNameFromId(prefix, tableId);
        return
            string(
                abi.encodePacked(
                    "INSERT INTO ",
                    name,
                    "(",
                    columns,
                    ")VALUES(",
                    values,
                    ")"
                )
            );
    }

    /**
     * @dev Generates an INSERT statement based on table prefix, tableId, columns, and values.
     *
     * prefix - the user generated table prefix as a string.
     * tableId - the Tableland generated tableId as a uint256.
     * columns - a string encoded ordered list of columns that will be updated. Example: "name, age".
     * values - an array where each item is a string encoded ordered list of values.
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toBatchInsert(
        string memory prefix,
        uint256 tableId,
        string memory columns,
        string[] memory values
    ) internal view returns (string memory) {
        string memory name = toNameFromId(prefix, tableId);
        string memory insert = string(
            abi.encodePacked("INSERT INTO ", name, "(", columns, ")VALUES")
        );
        for (uint256 i = 0; i < values.length; i++) {
            if (i == 0) {
                insert = string(abi.encodePacked(insert, "(", values[i], ")"));
            } else {
                insert = string(abi.encodePacked(insert, ",(", values[i], ")"));
            }
        }
        return insert;
    }

    /**
     * @dev Generates an Update statement based on table prefix, tableId, setters, and filters.
     *
     * prefix - the user generated table prefix as a string
     * tableId - the Tableland generated tableId as a uint256
     * setters - a string encoded set of updates. Example: "name='tom', age=26"
     * filters - a string encoded list of filters or "" for no filters. Example: "id<2 and name!='jerry'"
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toUpdate(
        string memory prefix,
        uint256 tableId,
        string memory setters,
        string memory filters
    ) internal view returns (string memory) {
        string memory name = toNameFromId(prefix, tableId);
        string memory filter = "";
        if (bytes(filters).length > 0) {
            filter = string(abi.encodePacked(" WHERE ", filters));
        }
        return
            string(abi.encodePacked("UPDATE ", name, " SET ", setters, filter));
    }

    /**
     * @dev Generates a Delete statement based on table prefix, tableId, and filters.
     *
     * prefix - the user generated table prefix as a string.
     * tableId - the Tableland generated tableId as a uint256.
     * filters - a string encoded list of filters. Example: "id<2 and name!='jerry'".
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function toDelete(
        string memory prefix,
        uint256 tableId,
        string memory filters
    ) internal view returns (string memory) {
        string memory name = toNameFromId(prefix, tableId);
        return
            string(abi.encodePacked("DELETE FROM ", name, " WHERE ", filters));
    }

    /**
     * @dev Add single quotes around a string value
     *
     * input - any input value.
     *
     */
    function quote(string memory input) internal pure returns (string memory) {
        return string(abi.encodePacked("'", input, "'"));
    }
}

File 20 of 21 : TablelandDeployments.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../ITablelandTables.sol";

/**
 * @dev Helper library for getting an instance of ITablelandTables for the currently executing EVM chain.
 */
library TablelandDeployments {
    /**
     * Current chain does not have a TablelandTables deployment.
     */
    error ChainNotSupported(uint256 chainid);

    // TablelandTables address on Ethereum.
    address internal constant MAINNET =
        0x012969f7e3439a9B04025b5a049EB9BAD82A8C12;
    // TablelandTables address on Optimism.
    address internal constant OPTIMISTIC_ETHEREUM =
        0xfad44BF5B843dE943a09D4f3E84949A11d3aa3e6;
    // TablelandTables address on Polygon.
    address internal constant POLYGON =
        0x5c4e6A9e5C1e1BF445A062006faF19EA6c49aFeA;

    // TablelandTables address on Ethereum Goerli.
    address internal constant GOERLI =
        0xDA8EA22d092307874f30A1F277D1388dca0BA97a;
    // TablelandTables address on Optimism Goerli.
    address internal constant OPTIMISTIC_GOERLI =
        0xC72E8a7Be04f2469f8C2dB3F1BdF69A7D516aBbA;
    // TablelandTables address on Arbitrum Goerli.
    address internal constant ARBITRUM_GOERLI =
        0x033f69e8d119205089Ab15D340F5b797732f646b;
    // TablelandTables address on Polygon Mumbai.
    address internal constant POLYGON_MUMBAI =
        0x4b48841d4b32C4650E4ABc117A03FE8B51f38F68;

    // TablelandTables address on for use with https://github.com/tablelandnetwork/local-tableland.
    address internal constant LOCAL_TABLELAND =
        0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512;

    /**
     * @dev Returns an interface to Tableland for the currently executing EVM chain.
     *
     * The selection order is meant to reduce gas on more expensive chains.
     *
     * Requirements:
     *
     * - block.chainid must refer to a supported chain.
     */
    function get() internal view returns (ITablelandTables) {
        if (block.chainid == 1) {
            return ITablelandTables(MAINNET);
        } else if (block.chainid == 10) {
            return ITablelandTables(OPTIMISTIC_ETHEREUM);
        } else if (block.chainid == 137) {
            return ITablelandTables(POLYGON);
        } else if (block.chainid == 5) {
            return ITablelandTables(GOERLI);
        } else if (block.chainid == 420) {
            return ITablelandTables(OPTIMISTIC_GOERLI);
        } else if (block.chainid == 421613) {
            return ITablelandTables(ARBITRUM_GOERLI);
        } else if (block.chainid == 80001) {
            return ITablelandTables(POLYGON_MUMBAI);
        } else if (block.chainid == 31337) {
            return ITablelandTables(LOCAL_TABLELAND);
        } else {
            revert ChainNotSupported(block.chainid);
        }
    }
}

File 21 of 21 : ITablelandRigPilots.sol
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.10 <0.9.0;

/**
 * @dev Interface of a TablelandRigPilots compliant contract.
 */
interface ITablelandRigPilots {
    // Thrown when attempting to interact with non-owned Rigs.
    error Unauthorized();

    // Thrown if a Pilot's contract is not ERC-721 compliant or pilot ID is greater than a uint32.
    error InvalidCustomPilot(string msg);

    // Thrown when a Garage action is attempted while a Rig is in a `GarageStatus` that is invalid for it to be performed.
    error InvalidPilotStatus();

    // Thrown upon a batch pilot update error.
    error InvalidBatchPilotAction();

    // Values describing a Rig's Garage status.
    enum GarageStatus {
        UNTRAINED,
        TRAINING,
        PARKED,
        PILOTED
    }

    // Pilot info for a Rig.
    struct PilotInfo {
        // The garage status of the Rig
        GarageStatus status;
        // Starting block number of pilot's flight time
        uint64 started;
        // Whether or not the Rig can be piloted
        bool pilotable;
        // Address of the ERC-721 contract for the pilot
        address addr;
        // ERC-721 token ID of the pilot at `address`
        uint256 id;
    }

    /**
     * @dev Emitted when a Rig starts its training.
     */
    event Training(uint256 tokenId);

    /**
     * @dev Emitted when a Rig is piloted.
     */
    event Piloted(uint256 tokenId, address pilotContract, uint256 pilotId);

    /**
     * @dev Emitted when a Rig is parked.
     */
    event Parked(uint256 tokenId);

    /**
     * @dev Returns the address of the contract parent parent.
     */
    function parent() external view returns (address);

    /**
     * @dev Returns the Tableland table name for the pilot sessions table.
     */
    function pilotSessionsTable() external view returns (string memory);

    /**
     * @dev Retrieves pilot info for a Rig.
     *
     * tokenId - the unique Rig token identifier
     *
     * Requirements:
     *
     * - `tokenId` must exist
     */
    function pilotInfo(
        uint256 tokenId
    ) external view returns (PilotInfo memory);

    /**
     * @dev Returns a pilot's start time.
     *
     * tokenId - the unique Rig token identifier
     */
    function pilotStartTime(uint256 tokenId) external view returns (uint64);

    /**
     * @dev Trains a Rig for a period of 30 days, putting it in-flight.
     *
     * sender - the initiator address
     * tokenId - the unique Rig token identifier
     *
     * Requirements:
     *
     * - `sender` must own the Rig
     * - `tokenId` must exist
     * - pilot status must be valid (`UNTRAINED`)
     */
    function trainRig(address sender, uint256 tokenId) external;

    /**
     * @dev Puts a single Rig in flight with a "stock" trainer pilot.
     *
     * sender - the initiator address
     * tokenId - the unique Rig token identifier
     *
     * Requirements:
     *
     * - `tokenId` must exist
     * - `sender` must own the Rig
     * - Must already be trained & currently parked
     */
    function pilotRig(address sender, uint256 tokenId) external;

    /**
     * @dev Puts a single Rig in flight by setting a custom `Pilot`.
     *
     * sender - the initiator address
     * tokenId - the unique Rig token identifier
     * pilotContract - ERC-721 contract address of a desired Rig's pilot
     * pilotId - the unique token identifier at the target `pilotContract`
     *
     * Requirements:
     *
     * - `tokenId` must exist
     * - `sender` must own the Rig
     * - Ability to pilot must be `true` (trained & flying with trainer, or already trained & parked)
     * - `pilotContract` must be an ERC-721 contract; cannot be the Rigs contract
     * - `pilotId` must be owned by `msg.sender` at `pilotContract`
     * - `Pilot` can only be associated with one Rig at a time; parks the other Rig on conflict
     */
    function pilotRig(
        address sender,
        uint256 tokenId,
        address pilotContract,
        uint256 pilotId
    ) external;

    /**
     * @dev Parks a Rig and ends the current `Pilot` session.
     *
     * tokenId - the unique Rig token identifier
     * force - boolean to force park a Rig (contract owner only)
     *
     * Requirements:
     *
     * - `tokenId` must exist
     * - `sender` must own the Rig
     * - pilot status must be `TRAINING` or `PILOTED`
     * - pilot must have completed 30 days of training
     */
    function parkRig(uint256 tokenId, bool force) external;

    /**
     * @dev Updates the value of a pilot's `owner` in the current session, upon in-flight token transfers.
     *
     * tokenId - the unique Rig token identifier
     * newOwner - address of the new token owner
     *
     * Requirements:
     *
     * - A parent method should implement a check to verify a caller owns `tokenId`, then call `updateSessionOwner`
     */
    function updateSessionOwner(uint256 tokenId, address newOwner) external;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"chainid","type":"uint256"}],"name":"ChainNotSupported","type":"error"},{"inputs":[],"name":"InvalidBatchPilotAction","type":"error"},{"inputs":[{"internalType":"string","name":"msg","type":"string"}],"name":"InvalidCustomPilot","type":"error"},{"inputs":[],"name":"InvalidPilotStatus","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","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":"uint256","name":"tokenId","type":"uint256"}],"name":"Parked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"pilotContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"pilotId","type":"uint256"}],"name":"Piloted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Training","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"parent_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"parent","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"force","type":"bool"}],"name":"parkRig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pilotInfo","outputs":[{"components":[{"internalType":"enum ITablelandRigPilots.GarageStatus","name":"status","type":"uint8"},{"internalType":"uint64","name":"started","type":"uint64"},{"internalType":"bool","name":"pilotable","type":"bool"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"internalType":"struct ITablelandRigPilots.PilotInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pilotRig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"pilotAddr","type":"address"},{"internalType":"uint256","name":"pilotId","type":"uint256"}],"name":"pilotRig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pilotSessionsTable","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pilotStartTime","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"trainRig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"updateSessionOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60a06040523060805234801561001457600080fd5b50608051612fcc61004c6000396000818161038c015281816103d501528181610ccf01528181610d0f01526110430152612fcc6000f3fe6080604052600436106100fe5760003560e01c806352d1902d116100955780638da5cb5b116100645780638da5cb5b146102d55780638ff1a66e146102f35780638ffac3a214610315578063c4d66de814610342578063f2fde38b1461036257600080fd5b806352d1902d1461024b5780635564926f1461026e57806360f96a8f1461028e578063715018a6146102c057600080fd5b8063408ae6f9116100d1578063408ae6f9146101d8578063499c7757146101f85780634f1ef286146102185780634f95c6931461022b57600080fd5b80630ebf904914610103578063150b7a02146101515780633659cfe6146101965780633c86cedf146101b8575b600080fd5b34801561010f57600080fd5b5061013461011e3660046124e8565b61ffff16600090815260cb602052604090205490565b6040516001600160401b0390911681526020015b60405180910390f35b34801561015d57600080fd5b5061017d61016c366004612516565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610148565b3480156101a257600080fd5b506101b66101b13660046125b4565b610382565b005b3480156101c457600080fd5b506101b66101d33660046125d1565b61046a565b3480156101e457600080fd5b506101b66101f3366004612601565b6105a1565b34801561020457600080fd5b506101b661021336600461262d565b61075c565b6101b661022636600461268b565b610cc5565b34801561023757600080fd5b506101b661024636600461274e565b610d95565b34801561025757600080fd5b50610260611036565b604051908152602001610148565b34801561027a57600080fd5b506101b6610289366004612601565b6110e9565b34801561029a57600080fd5b5060c9546001600160a01b03165b6040516001600160a01b039091168152602001610148565b3480156102cc57600080fd5b506101b6611247565b3480156102e157600080fd5b506033546001600160a01b03166102a8565b3480156102ff57600080fd5b5061030861125b565b60405161014891906127d0565b34801561032157600080fd5b506103356103303660046124e8565b611294565b60405161014891906127f9565b34801561034e57600080fd5b506101b661035d3660046125b4565b611358565b34801561036e57600080fd5b506101b661037d3660046125b4565b611547565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036103d35760405162461bcd60e51b81526004016103ca90612863565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661041c600080516020612ebc833981519152546001600160a01b031690565b6001600160a01b0316146104425760405162461bcd60e51b81526004016103ca906128af565b61044b816115bd565b60408051600080825260208201909252610467918391906115c5565b50565b610472611735565b61ffff8216600090815260cb6020526040812054906104986104938461178f565b6117ab565b6040516020016104a891906128fb565b604051602081830303815290604052905060006104c88561ffff166117d4565b6104da846001600160401b03166117d4565b6040516020016104eb929190612929565b60405160208183030381529060405290506105046118dc565b6001600160a01b031663eaf5d04e3060ca5461054a6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548888611a07565b6040518463ffffffff1660e01b815260040161056893929190612990565b600060405180830381600087803b15801561058257600080fd5b505af1158015610596573d6000803e3d6000fd5b505050505050505050565b6105a9611735565b60026105b482611a82565b60038111156105c5576105c56127e3565b146105e3576040516309380d7960e21b815260040160405180910390fd5b6105f08160006002611afd565b6105fa8143611b31565b6106026118dc565b6001600160a01b031663eaf5d04e3060ca546106c26040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54604051806040016040528060178152602001767269675f69642c6f776e65722c73746172745f74696d6560481b81525061067e8961ffff166117d4565b61068a6104938c61178f565b61069c436001600160401b03166117d4565b6040516020016106ae939291906129b7565b604051602081830303815290604052611b8a565b6040518463ffffffff1660e01b81526004016106e093929190612990565b600060405180830381600087803b1580156106fa57600080fd5b505af115801561070e573d6000803e3d6000fd5b505060408051848152600060208201526002918101919091527f94f399a21eca6d301c36565edb4c860cdeb04be2338b8c9af004f600d794cd3e925060600190505b60405180910390a15050565b610764611735565b63ffffffff8111156107ac5760405163fd86c4af60e01b815260206004820152601060248201526f70696c6f7420696420746f6f2062696760801b60448201526064016103ca565b60c9546001600160a01b03838116911614806107df57506107dd6001600160a01b0383166380ac58cd60e01b611bc9565b155b1561082d5760405163fd86c4af60e01b815260206004820152601c60248201527f70696c6f7420636f6e7472616374206e6f7420737570706f727465640000000060448201526064016103ca565b6040516331a9108f60e11b8152600481018290526001600160a01b038086169190841690636352211e90602401602060405180830381865afa158015610877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089b9190612a11565b6001600160a01b0316146108e15760405163fd86c4af60e01b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b60448201526064016103ca565b6108ea83611bec565b610907576040516309380d7960e21b815260040160405180910390fd5b602082811b640100000000600160c01b03166001600160c01b0383168117600090815260cc9092526040909120549082179061ffff161580159061096757506001600160c01b038116600090815260cc602052604090205461ffff168414155b80156109aa575060026001600160c01b038216600090815260cc60205260409020546109969061ffff16611a82565b60038111156109a7576109a76127e3565b14155b156109d8576001600160c01b038116600090815260cc60205260408120546109d89161ffff90911690610d95565b60016109e385611a82565b60038111156109f4576109f46127e3565b03610b2b576000610a0d436001600160401b03166117d4565b604051602001610a1d9190612a2e565b60405160208183030381529060405290506000610a3d8661ffff166117d4565b610a68610a5a8861ffff16600090815260cb602052604090205490565b6001600160401b03166117d4565b604051602001610a79929190612929565b6040516020818303038152906040529050610a926118dc565b6001600160a01b031663eaf5d04e3060ca54610ad86040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548888611a07565b6040518463ffffffff1660e01b8152600401610af693929190612990565b600060405180830381600087803b158015610b1057600080fd5b505af1158015610b24573d6000803e3d6000fd5b5050505050505b610b358443611b31565b610b3d6118dc565b6001600160a01b031663eaf5d04e3060ca54610bef6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca546040518060600160405280602f8152602001612e8d602f9139610ba28c61ffff166117d4565b610bae6104938f61178f565b610bba6104938e611c6c565b610bc98d63ffffffff166117d4565b610bdb436001600160401b03166117d4565b6040516020016106ae959493929190612a5f565b6040518463ffffffff1660e01b8152600401610c0d93929190612990565b600060405180830381600087803b158015610c2757600080fd5b505af1158015610c3b573d6000803e3d6000fd5b50505050610c4a848484611afd565b6001600160c01b038116600090815260cc6020908152604091829020805461ffff191661ffff881617905581518681526001600160a01b038616918101919091529081018390527f94f399a21eca6d301c36565edb4c860cdeb04be2338b8c9af004f600d794cd3e9060600160405180910390a15050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610d0d5760405162461bcd60e51b81526004016103ca90612863565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610d56600080516020612ebc833981519152546001600160a01b031690565b6001600160a01b031614610d7c5760405162461bcd60e51b81526004016103ca906128af565b610d85826115bd565b610d91828260016115c5565b5050565b610d9d611735565b6000610da883611a82565b90506001816003811115610dbe57610dbe6127e3565b1480610ddb57506003816003811115610dd957610dd96127e3565b145b610df8576040516309380d7960e21b815260040160405180910390fd5b60606000610e168561ffff16600090815260cb602052604090205490565b905060006001846003811115610e2e57610e2e6127e3565b148015610e4f5750610e4c6202a3006001600160401b038416612b0b565b43105b905060006001856003811115610e6757610e676127e3565b148015610e715750855b90508180610e7c5750805b15610e8d57610e8d87600080611afd565b8180610e965750855b15610ed357610ead836001600160401b03166117d4565b604051602001610ebd9190612a2e565b6040516020818303038152906040529350610f07565b610ee5436001600160401b03166117d4565b604051602001610ef59190612a2e565b60405160208183030381529060405293505b6000610f168861ffff166117d4565b610f28856001600160401b03166117d4565b604051602001610f39929190612929565b6040516020818303038152906040529050610f55886000611b31565b610f5d6118dc565b6001600160a01b031663eaf5d04e3060ca54610fa36040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548b88611a07565b6040518463ffffffff1660e01b8152600401610fc193929190612990565b600060405180830381600087803b158015610fdb57600080fd5b505af1158015610fef573d6000803e3d6000fd5b505050507f012144d6cf470e181d56704cd615b18893e8c51dc6d304c43b3c8556ce6c360d8860405161102491815260200190565b60405180910390a15050505050505050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146110d65760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c000000000000000060648201526084016103ca565b50600080516020612ebc83398151915290565b6110f1611735565b60006110fc82611a82565b600381111561110d5761110d6127e3565b1461112b576040516309380d7960e21b815260040160405180910390fd5b6111358143611b31565b6111428160006001611afd565b61114a6118dc565b6001600160a01b031663eaf5d04e3060ca546111c66040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54604051806040016040528060178152602001767269675f69642c6f776e65722c73746172745f74696d6560481b81525061067e8961ffff166117d4565b6040518463ffffffff1660e01b81526004016111e493929190612990565b600060405180830381600087803b1580156111fe57600080fd5b505af1158015611212573d6000803e3d6000fd5b505050507f3b7fd516f1f5a99dd9ffe218a553d6ebc92081ee45f0466f8be3b39729ef9ca18160405161075091815260200190565b61124f611c82565b6112596000611cdc565b565b606061128f6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54611d2e565b905090565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526040518060a001604052806112d384611a82565b60038111156112e4576112e46127e3565b81526020016113038461ffff16600090815260cb602052604090205490565b6001600160401b0316815260200161131a84611bec565b1515815261ffff93909316600081815260cb6020818152604080842054606081901c838a0152949093525290811c63ffffffff169301929092525090565b600054610100900460ff16158080156113785750600054600160ff909116105b806113925750303b158015611392575060005460ff166001145b6113f55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103ca565b6000805460ff191660011790558015611418576000805461ff0019166101001790555b611420611d6c565b611428611d9b565b60c980546001600160a01b0319166001600160a01b03841617905561144b6118dc565b6001600160a01b0316633a9151b0306114a26040518060c0016040528060948152602001612edc609491396040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b815250611dc2565b6040518363ffffffff1660e01b81526004016114bf929190612b23565b6020604051808303816000875af11580156114de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115029190612b47565b60ca558015610d91576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610750565b61154f611c82565b6001600160a01b0381166115b45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103ca565b61046781611cdc565b610467611c82565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156115fd576115f883611de1565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611657575060408051601f3d908101601f1916820190925261165491810190612b47565b60015b6116ba5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016103ca565b600080516020612ebc83398151915281146117295760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016103ca565b506115f8838383611e7d565b60c9546001600160a01b031633146112595760405162461bcd60e51b815260206004820181905260248201527f50696c6f74733a2063616c6c6572206973206e6f742074686520706172656e7460448201526064016103ca565b60606117a56001600160a01b0383166014611ea8565b92915050565b6060816040516020016117be9190612b60565b6040516020818303038152906040529050919050565b6060816000036117fb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611825578061180f81612b8e565b915061181e9050600a83612bbd565b91506117ff565b6000816001600160401b0381111561183f5761183f612675565b6040519080825280601f01601f191660200182016040528015611869576020820181803683370190505b5090505b84156118d45761187e600183612bd1565b915061188b600a86612be8565b611896906030612b0b565b60f81b8183815181106118ab576118ab612bfc565b60200101906001600160f81b031916908160001a9053506118cd600a86612bbd565b945061186d565b949350505050565b6000466001036118ff575073012969f7e3439a9b04025b5a049eb9bad82a8c1290565b46600a03611920575073fad44bf5b843de943a09d4f3e84949a11d3aa3e690565b466089036119415750735c4e6a9e5c1e1bf445a062006faf19ea6c49afea90565b46600503611962575073da8ea22d092307874f30a1f277d1388dca0ba97a90565b466101a403611984575073c72e8a7be04f2469f8c2db3f1bdf69a7d516abba90565b4662066eed036119a7575073033f69e8d119205089ab15d340f5b797732f646b90565b4662013881036119ca5750734b48841d4b32c4650e4abc117a03fe8b51f38f6890565b46617a69036119ec575073e7f1725e7734ce288f8367e1bb143e90bb3f051290565b60405163264e42cf60e01b81524660048201526024016103ca565b60606000611a158686611d2e565b60408051602081019091526000815284519192509015611a525783604051602001611a409190612c12565b60405160208183030381529060405290505b818582604051602001611a6793929190612c41565b60405160208183030381529060405292505050949350505050565b61ffff8116600090815260cb60205260408120546001600160401b031615611ad15761ffff8216600090815260cb602052604090819020546001911c14611aca5760036117a5565b60016117a5565b61ffff8216600090815260cb60205260409081902054901c15611af55760026117a5565b600092915050565b61ffff909216600090815260cb60205260409081902080546001600160401b03169390911b9290921760609190911b179055565b61ffff8216600090815260cb602052604090205481908115611b605767ffffffffffffffff1981168217611b6d565b67ffffffffffffffff1981165b61ffff909416600090815260cb6020526040902093909355505050565b60606000611b988686611d2e565b9050808484604051602001611baf93929190612cab565b604051602081830303815290604052915050949350505050565b6000611bd483612043565b8015611be55750611be58383612076565b9392505050565b600080611bf883611a82565b90506002816003811115611c0e57611c0e6127e3565b1480611be557506001816003811115611c2957611c296127e3565b148015611be557506202a300611c4f8461ffff16600090815260cb602052604090205490565b6001600160401b0316611c629190612b0b565b4310159392505050565b60606117a56001600160a01b03831660146120ff565b6033546001600160a01b031633146112595760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ca565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606082611d3a4661224b565b611d438461224b565b604051602001611d5593929190612d37565b604051602081830303815290604052905092915050565b600054610100900460ff16611d935760405162461bcd60e51b81526004016103ca90612d69565b61125961234b565b600054610100900460ff166112595760405162461bcd60e51b81526004016103ca90612d69565b606081611dce4661224b565b84604051602001611d5593929190612db4565b6001600160a01b0381163b611e4e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016103ca565b600080516020612ebc83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611e868361237b565b600082511180611e935750805b156115f857611ea283836123bb565b50505050565b60606000611eb7836002612e3a565b611ec2906002612b0b565b6001600160401b03811115611ed957611ed9612675565b6040519080825280601f01601f191660200182016040528015611f03576020820181803683370190505b509050600360fc1b81600081518110611f1e57611f1e612bfc565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611f4d57611f4d612bfc565b60200101906001600160f81b031916908160001a9053506000611f71846002612e3a565b611f7c906001612b0b565b90505b6001811115611ff4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611fb057611fb0612bfc565b1a60f81b828281518110611fc657611fc6612bfc565b60200101906001600160f81b031916908160001a90535060049490941c93611fed81612e59565b9050611f7f565b508315611be55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016103ca565b6000612056826301ffc9a760e01b612076565b80156117a5575061206f826001600160e01b0319612076565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156120e8575060208210155b80156120f45750600081115b979650505050505050565b6060600061210e836002612e3a565b612119906002612b0b565b6001600160401b0381111561213057612130612675565b6040519080825280601f01601f19166020018201604052801561215a576020820181803683370190505b509050600360fc1b8160008151811061217557612175612bfc565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106121a4576121a4612bfc565b60200101906001600160f81b031916908160001a90535060006121c8846002612e3a565b6121d3906001612b0b565b90505b6001811115611ff4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061220757612207612bfc565b1a60f81b82828151811061221d5761221d612bfc565b60200101906001600160f81b031916908160001a90535060049490941c9361224481612e59565b90506121d6565b6060816000036122725750506040805180820190915260018152600360fc1b602082015290565b8160005b811561229c578061228681612b8e565b91506122959050600a83612bbd565b9150612276565b6000816001600160401b038111156122b6576122b6612675565b6040519080825280601f01601f1916602001820160405280156122e0576020820181803683370190505b5090505b84156118d4576122f5600183612bd1565b9150612302600a86612be8565b61230d906030612b0b565b60f81b81838151811061232257612322612bfc565b60200101906001600160f81b031916908160001a905350612344600a86612bbd565b94506122e4565b600054610100900460ff166123725760405162461bcd60e51b81526004016103ca90612d69565b61125933611cdc565b61238481611de1565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6124235760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016103ca565b600080846001600160a01b03168460405161243e9190612e70565b600060405180830381855af49150503d8060008114612479576040519150601f19603f3d011682016040523d82523d6000602084013e61247e565b606091505b50915091506124a68282604051806060016040528060278152602001612f70602791396124af565b95945050505050565b606083156124be575081611be5565b8251156124ce5782518084602001fd5b8160405162461bcd60e51b81526004016103ca91906127d0565b6000602082840312156124fa57600080fd5b5035919050565b6001600160a01b038116811461046757600080fd5b60008060008060006080868803121561252e57600080fd5b853561253981612501565b9450602086013561254981612501565b93506040860135925060608601356001600160401b038082111561256c57600080fd5b818801915088601f83011261258057600080fd5b81358181111561258f57600080fd5b8960208285010111156125a157600080fd5b9699959850939650602001949392505050565b6000602082840312156125c657600080fd5b8135611be581612501565b600080604083850312156125e457600080fd5b8235915060208301356125f681612501565b809150509250929050565b6000806040838503121561261457600080fd5b823561261f81612501565b946020939093013593505050565b6000806000806080858703121561264357600080fd5b843561264e81612501565b935060208501359250604085013561266581612501565b9396929550929360600135925050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561269e57600080fd5b82356126a981612501565b915060208301356001600160401b03808211156126c557600080fd5b818501915085601f8301126126d957600080fd5b8135818111156126eb576126eb612675565b604051601f8201601f19908116603f0116810190838211818310171561271357612713612675565b8160405282815288602084870101111561272c57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000806040838503121561276157600080fd5b82359150602083013580151581146125f657600080fd5b60005b8381101561279357818101518382015260200161277b565b83811115611ea25750506000910152565b600081518084526127bc816020860160208601612778565b601f01601f19169290920160200192915050565b602081526000611be560208301846127a4565b634e487b7160e01b600052602160045260246000fd5b815160a08201906004811061281e57634e487b7160e01b600052602160045260246000fd5b82526020838101516001600160401b0316908301526040808401511515908301526060808401516001600160a01b031690830152608092830151929091019190915290565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b656f776e65723d60d01b81526000825161291c816006850160208701612778565b9190910160060192915050565b667269675f69643d60c81b81526000835161294b816007850160208801612778565b6401030b732160dd1b6007918401918201526a73746172745f74696d653d60a81b600c8201528351612984816017840160208801612778565b01601701949350505050565b60018060a01b03841681528260208201526060604082015260006124a660608301846127a4565b600084516129c9818460208901612778565b8083019050600b60fa1b80825285516129e9816001850160208a01612778565b60019201918201528351612a04816002840160208801612778565b0160020195945050505050565b600060208284031215612a2357600080fd5b8151611be581612501565b68656e645f74696d653d60b81b815260008251612a52816009850160208701612778565b9190910160090192915050565b60008651612a71818460208b01612778565b8083019050600b60fa1b8082528751612a91816001850160208c01612778565b600192019182018190528651612aae816002850160208b01612778565b600292019182018190528551612acb816003850160208a01612778565b60039201918201528351612ae6816004840160208801612778565b01600401979650505050505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612b1e57612b1e612af5565b500190565b6001600160a01b03831681526040602082018190526000906118d4908301846127a4565b600060208284031215612b5957600080fd5b5051919050565b6000602760f81b8083528351612b7d816001860160208801612778565b600193019283015250600201919050565b600060018201612ba057612ba0612af5565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082612bcc57612bcc612ba7565b500490565b600082821015612be357612be3612af5565b500390565b600082612bf757612bf7612ba7565b500690565b634e487b7160e01b600052603260045260246000fd5b660102ba422a922960cd1b815260008251612c34816007850160208701612778565b9190910160070192915050565b6602aa82220aa22960cd1b815260008451612c63816007850160208901612778565b6401029a2aa160dd1b6007918401918201528451612c8881600c840160208901612778565b8451910190612c9e81600c840160208801612778565b01600c0195945050505050565b6b024a729a2a92a1024a72a27960a51b815260008451612cd281600c850160208901612778565b600560fb1b600c918401918201528451612cf381600d840160208901612778565b67052ac8298aa8aa6560c31b600d92909101918201528351612d1c816015840160208801612778565b602960f81b6015929091019182015260160195945050505050565b60008451612d49818460208901612778565b8083019050605f60f81b80825285516129e9816001850160208a01612778565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6c021a922a0aa22902a20a126229609d1b815260008451612ddc81600d850160208901612778565b605f60f81b600d918401918201528451612dfd81600e840160208901612778565b600560fb1b600e92909101918201528351612e1f81600f840160208801612778565b602960f81b600f929091019182015260100195945050505050565b6000816000190483118215151615612e5457612e54612af5565b500290565b600081612e6857612e68612af5565b506000190190565b60008251612e82818460208701612778565b919091019291505056fe7269675f69642c6f776e65722c70696c6f745f636f6e74726163742c70696c6f745f69642c73746172745f74696d65360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc696420696e7465676572207072696d617279206b65792c7269675f696420696e7465676572206e6f74206e756c6c2c6f776e65722074657874206e6f74206e756c6c2c70696c6f745f636f6e747261637420746578742c70696c6f745f696420696e74656765722c73746172745f74696d6520696e7465676572206e6f74206e756c6c2c656e645f74696d6520696e7465676572416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f61075283da4e2ced15d4f534e53896cf772a854fc191549d54c442dd07e0f0464736f6c634300080f0033

Deployed Bytecode

0x6080604052600436106100fe5760003560e01c806352d1902d116100955780638da5cb5b116100645780638da5cb5b146102d55780638ff1a66e146102f35780638ffac3a214610315578063c4d66de814610342578063f2fde38b1461036257600080fd5b806352d1902d1461024b5780635564926f1461026e57806360f96a8f1461028e578063715018a6146102c057600080fd5b8063408ae6f9116100d1578063408ae6f9146101d8578063499c7757146101f85780634f1ef286146102185780634f95c6931461022b57600080fd5b80630ebf904914610103578063150b7a02146101515780633659cfe6146101965780633c86cedf146101b8575b600080fd5b34801561010f57600080fd5b5061013461011e3660046124e8565b61ffff16600090815260cb602052604090205490565b6040516001600160401b0390911681526020015b60405180910390f35b34801561015d57600080fd5b5061017d61016c366004612516565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610148565b3480156101a257600080fd5b506101b66101b13660046125b4565b610382565b005b3480156101c457600080fd5b506101b66101d33660046125d1565b61046a565b3480156101e457600080fd5b506101b66101f3366004612601565b6105a1565b34801561020457600080fd5b506101b661021336600461262d565b61075c565b6101b661022636600461268b565b610cc5565b34801561023757600080fd5b506101b661024636600461274e565b610d95565b34801561025757600080fd5b50610260611036565b604051908152602001610148565b34801561027a57600080fd5b506101b6610289366004612601565b6110e9565b34801561029a57600080fd5b5060c9546001600160a01b03165b6040516001600160a01b039091168152602001610148565b3480156102cc57600080fd5b506101b6611247565b3480156102e157600080fd5b506033546001600160a01b03166102a8565b3480156102ff57600080fd5b5061030861125b565b60405161014891906127d0565b34801561032157600080fd5b506103356103303660046124e8565b611294565b60405161014891906127f9565b34801561034e57600080fd5b506101b661035d3660046125b4565b611358565b34801561036e57600080fd5b506101b661037d3660046125b4565b611547565b6001600160a01b037f000000000000000000000000d7e5d69893699cdd76417c9b0947a1043a3c4b581630036103d35760405162461bcd60e51b81526004016103ca90612863565b60405180910390fd5b7f000000000000000000000000d7e5d69893699cdd76417c9b0947a1043a3c4b586001600160a01b031661041c600080516020612ebc833981519152546001600160a01b031690565b6001600160a01b0316146104425760405162461bcd60e51b81526004016103ca906128af565b61044b816115bd565b60408051600080825260208201909252610467918391906115c5565b50565b610472611735565b61ffff8216600090815260cb6020526040812054906104986104938461178f565b6117ab565b6040516020016104a891906128fb565b604051602081830303815290604052905060006104c88561ffff166117d4565b6104da846001600160401b03166117d4565b6040516020016104eb929190612929565b60405160208183030381529060405290506105046118dc565b6001600160a01b031663eaf5d04e3060ca5461054a6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548888611a07565b6040518463ffffffff1660e01b815260040161056893929190612990565b600060405180830381600087803b15801561058257600080fd5b505af1158015610596573d6000803e3d6000fd5b505050505050505050565b6105a9611735565b60026105b482611a82565b60038111156105c5576105c56127e3565b146105e3576040516309380d7960e21b815260040160405180910390fd5b6105f08160006002611afd565b6105fa8143611b31565b6106026118dc565b6001600160a01b031663eaf5d04e3060ca546106c26040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54604051806040016040528060178152602001767269675f69642c6f776e65722c73746172745f74696d6560481b81525061067e8961ffff166117d4565b61068a6104938c61178f565b61069c436001600160401b03166117d4565b6040516020016106ae939291906129b7565b604051602081830303815290604052611b8a565b6040518463ffffffff1660e01b81526004016106e093929190612990565b600060405180830381600087803b1580156106fa57600080fd5b505af115801561070e573d6000803e3d6000fd5b505060408051848152600060208201526002918101919091527f94f399a21eca6d301c36565edb4c860cdeb04be2338b8c9af004f600d794cd3e925060600190505b60405180910390a15050565b610764611735565b63ffffffff8111156107ac5760405163fd86c4af60e01b815260206004820152601060248201526f70696c6f7420696420746f6f2062696760801b60448201526064016103ca565b60c9546001600160a01b03838116911614806107df57506107dd6001600160a01b0383166380ac58cd60e01b611bc9565b155b1561082d5760405163fd86c4af60e01b815260206004820152601c60248201527f70696c6f7420636f6e7472616374206e6f7420737570706f727465640000000060448201526064016103ca565b6040516331a9108f60e11b8152600481018290526001600160a01b038086169190841690636352211e90602401602060405180830381865afa158015610877573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089b9190612a11565b6001600160a01b0316146108e15760405163fd86c4af60e01b815260206004820152600c60248201526b1d5b985d5d1a1bdc9a5e995960a21b60448201526064016103ca565b6108ea83611bec565b610907576040516309380d7960e21b815260040160405180910390fd5b602082811b640100000000600160c01b03166001600160c01b0383168117600090815260cc9092526040909120549082179061ffff161580159061096757506001600160c01b038116600090815260cc602052604090205461ffff168414155b80156109aa575060026001600160c01b038216600090815260cc60205260409020546109969061ffff16611a82565b60038111156109a7576109a76127e3565b14155b156109d8576001600160c01b038116600090815260cc60205260408120546109d89161ffff90911690610d95565b60016109e385611a82565b60038111156109f4576109f46127e3565b03610b2b576000610a0d436001600160401b03166117d4565b604051602001610a1d9190612a2e565b60405160208183030381529060405290506000610a3d8661ffff166117d4565b610a68610a5a8861ffff16600090815260cb602052604090205490565b6001600160401b03166117d4565b604051602001610a79929190612929565b6040516020818303038152906040529050610a926118dc565b6001600160a01b031663eaf5d04e3060ca54610ad86040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548888611a07565b6040518463ffffffff1660e01b8152600401610af693929190612990565b600060405180830381600087803b158015610b1057600080fd5b505af1158015610b24573d6000803e3d6000fd5b5050505050505b610b358443611b31565b610b3d6118dc565b6001600160a01b031663eaf5d04e3060ca54610bef6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca546040518060600160405280602f8152602001612e8d602f9139610ba28c61ffff166117d4565b610bae6104938f61178f565b610bba6104938e611c6c565b610bc98d63ffffffff166117d4565b610bdb436001600160401b03166117d4565b6040516020016106ae959493929190612a5f565b6040518463ffffffff1660e01b8152600401610c0d93929190612990565b600060405180830381600087803b158015610c2757600080fd5b505af1158015610c3b573d6000803e3d6000fd5b50505050610c4a848484611afd565b6001600160c01b038116600090815260cc6020908152604091829020805461ffff191661ffff881617905581518681526001600160a01b038616918101919091529081018390527f94f399a21eca6d301c36565edb4c860cdeb04be2338b8c9af004f600d794cd3e9060600160405180910390a15050505050565b6001600160a01b037f000000000000000000000000d7e5d69893699cdd76417c9b0947a1043a3c4b58163003610d0d5760405162461bcd60e51b81526004016103ca90612863565b7f000000000000000000000000d7e5d69893699cdd76417c9b0947a1043a3c4b586001600160a01b0316610d56600080516020612ebc833981519152546001600160a01b031690565b6001600160a01b031614610d7c5760405162461bcd60e51b81526004016103ca906128af565b610d85826115bd565b610d91828260016115c5565b5050565b610d9d611735565b6000610da883611a82565b90506001816003811115610dbe57610dbe6127e3565b1480610ddb57506003816003811115610dd957610dd96127e3565b145b610df8576040516309380d7960e21b815260040160405180910390fd5b60606000610e168561ffff16600090815260cb602052604090205490565b905060006001846003811115610e2e57610e2e6127e3565b148015610e4f5750610e4c6202a3006001600160401b038416612b0b565b43105b905060006001856003811115610e6757610e676127e3565b148015610e715750855b90508180610e7c5750805b15610e8d57610e8d87600080611afd565b8180610e965750855b15610ed357610ead836001600160401b03166117d4565b604051602001610ebd9190612a2e565b6040516020818303038152906040529350610f07565b610ee5436001600160401b03166117d4565b604051602001610ef59190612a2e565b60405160208183030381529060405293505b6000610f168861ffff166117d4565b610f28856001600160401b03166117d4565b604051602001610f39929190612929565b6040516020818303038152906040529050610f55886000611b31565b610f5d6118dc565b6001600160a01b031663eaf5d04e3060ca54610fa36040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca548b88611a07565b6040518463ffffffff1660e01b8152600401610fc193929190612990565b600060405180830381600087803b158015610fdb57600080fd5b505af1158015610fef573d6000803e3d6000fd5b505050507f012144d6cf470e181d56704cd615b18893e8c51dc6d304c43b3c8556ce6c360d8860405161102491815260200190565b60405180910390a15050505050505050565b6000306001600160a01b037f000000000000000000000000d7e5d69893699cdd76417c9b0947a1043a3c4b5816146110d65760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c000000000000000060648201526084016103ca565b50600080516020612ebc83398151915290565b6110f1611735565b60006110fc82611a82565b600381111561110d5761110d6127e3565b1461112b576040516309380d7960e21b815260040160405180910390fd5b6111358143611b31565b6111428160006001611afd565b61114a6118dc565b6001600160a01b031663eaf5d04e3060ca546111c66040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54604051806040016040528060178152602001767269675f69642c6f776e65722c73746172745f74696d6560481b81525061067e8961ffff166117d4565b6040518463ffffffff1660e01b81526004016111e493929190612990565b600060405180830381600087803b1580156111fe57600080fd5b505af1158015611212573d6000803e3d6000fd5b505050507f3b7fd516f1f5a99dd9ffe218a553d6ebc92081ee45f0466f8be3b39729ef9ca18160405161075091815260200190565b61124f611c82565b6112596000611cdc565b565b606061128f6040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b81525060ca54611d2e565b905090565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526040518060a001604052806112d384611a82565b60038111156112e4576112e46127e3565b81526020016113038461ffff16600090815260cb602052604090205490565b6001600160401b0316815260200161131a84611bec565b1515815261ffff93909316600081815260cb6020818152604080842054606081901c838a0152949093525290811c63ffffffff169301929092525090565b600054610100900460ff16158080156113785750600054600160ff909116105b806113925750303b158015611392575060005460ff166001145b6113f55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103ca565b6000805460ff191660011790558015611418576000805461ff0019166101001790555b611420611d6c565b611428611d9b565b60c980546001600160a01b0319166001600160a01b03841617905561144b6118dc565b6001600160a01b0316633a9151b0306114a26040518060c0016040528060948152602001612edc609491396040518060400160405280600e81526020016d70696c6f745f73657373696f6e7360901b815250611dc2565b6040518363ffffffff1660e01b81526004016114bf929190612b23565b6020604051808303816000875af11580156114de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115029190612b47565b60ca558015610d91576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602001610750565b61154f611c82565b6001600160a01b0381166115b45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103ca565b61046781611cdc565b610467611c82565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156115fd576115f883611de1565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611657575060408051601f3d908101601f1916820190925261165491810190612b47565b60015b6116ba5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016103ca565b600080516020612ebc83398151915281146117295760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016103ca565b506115f8838383611e7d565b60c9546001600160a01b031633146112595760405162461bcd60e51b815260206004820181905260248201527f50696c6f74733a2063616c6c6572206973206e6f742074686520706172656e7460448201526064016103ca565b60606117a56001600160a01b0383166014611ea8565b92915050565b6060816040516020016117be9190612b60565b6040516020818303038152906040529050919050565b6060816000036117fb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611825578061180f81612b8e565b915061181e9050600a83612bbd565b91506117ff565b6000816001600160401b0381111561183f5761183f612675565b6040519080825280601f01601f191660200182016040528015611869576020820181803683370190505b5090505b84156118d45761187e600183612bd1565b915061188b600a86612be8565b611896906030612b0b565b60f81b8183815181106118ab576118ab612bfc565b60200101906001600160f81b031916908160001a9053506118cd600a86612bbd565b945061186d565b949350505050565b6000466001036118ff575073012969f7e3439a9b04025b5a049eb9bad82a8c1290565b46600a03611920575073fad44bf5b843de943a09d4f3e84949a11d3aa3e690565b466089036119415750735c4e6a9e5c1e1bf445a062006faf19ea6c49afea90565b46600503611962575073da8ea22d092307874f30a1f277d1388dca0ba97a90565b466101a403611984575073c72e8a7be04f2469f8c2db3f1bdf69a7d516abba90565b4662066eed036119a7575073033f69e8d119205089ab15d340f5b797732f646b90565b4662013881036119ca5750734b48841d4b32c4650e4abc117a03fe8b51f38f6890565b46617a69036119ec575073e7f1725e7734ce288f8367e1bb143e90bb3f051290565b60405163264e42cf60e01b81524660048201526024016103ca565b60606000611a158686611d2e565b60408051602081019091526000815284519192509015611a525783604051602001611a409190612c12565b60405160208183030381529060405290505b818582604051602001611a6793929190612c41565b60405160208183030381529060405292505050949350505050565b61ffff8116600090815260cb60205260408120546001600160401b031615611ad15761ffff8216600090815260cb602052604090819020546001911c14611aca5760036117a5565b60016117a5565b61ffff8216600090815260cb60205260409081902054901c15611af55760026117a5565b600092915050565b61ffff909216600090815260cb60205260409081902080546001600160401b03169390911b9290921760609190911b179055565b61ffff8216600090815260cb602052604090205481908115611b605767ffffffffffffffff1981168217611b6d565b67ffffffffffffffff1981165b61ffff909416600090815260cb6020526040902093909355505050565b60606000611b988686611d2e565b9050808484604051602001611baf93929190612cab565b604051602081830303815290604052915050949350505050565b6000611bd483612043565b8015611be55750611be58383612076565b9392505050565b600080611bf883611a82565b90506002816003811115611c0e57611c0e6127e3565b1480611be557506001816003811115611c2957611c296127e3565b148015611be557506202a300611c4f8461ffff16600090815260cb602052604090205490565b6001600160401b0316611c629190612b0b565b4310159392505050565b60606117a56001600160a01b03831660146120ff565b6033546001600160a01b031633146112595760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ca565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b606082611d3a4661224b565b611d438461224b565b604051602001611d5593929190612d37565b604051602081830303815290604052905092915050565b600054610100900460ff16611d935760405162461bcd60e51b81526004016103ca90612d69565b61125961234b565b600054610100900460ff166112595760405162461bcd60e51b81526004016103ca90612d69565b606081611dce4661224b565b84604051602001611d5593929190612db4565b6001600160a01b0381163b611e4e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016103ca565b600080516020612ebc83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b611e868361237b565b600082511180611e935750805b156115f857611ea283836123bb565b50505050565b60606000611eb7836002612e3a565b611ec2906002612b0b565b6001600160401b03811115611ed957611ed9612675565b6040519080825280601f01601f191660200182016040528015611f03576020820181803683370190505b509050600360fc1b81600081518110611f1e57611f1e612bfc565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611f4d57611f4d612bfc565b60200101906001600160f81b031916908160001a9053506000611f71846002612e3a565b611f7c906001612b0b565b90505b6001811115611ff4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611fb057611fb0612bfc565b1a60f81b828281518110611fc657611fc6612bfc565b60200101906001600160f81b031916908160001a90535060049490941c93611fed81612e59565b9050611f7f565b508315611be55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016103ca565b6000612056826301ffc9a760e01b612076565b80156117a5575061206f826001600160e01b0319612076565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156120e8575060208210155b80156120f45750600081115b979650505050505050565b6060600061210e836002612e3a565b612119906002612b0b565b6001600160401b0381111561213057612130612675565b6040519080825280601f01601f19166020018201604052801561215a576020820181803683370190505b509050600360fc1b8160008151811061217557612175612bfc565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106121a4576121a4612bfc565b60200101906001600160f81b031916908160001a90535060006121c8846002612e3a565b6121d3906001612b0b565b90505b6001811115611ff4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061220757612207612bfc565b1a60f81b82828151811061221d5761221d612bfc565b60200101906001600160f81b031916908160001a90535060049490941c9361224481612e59565b90506121d6565b6060816000036122725750506040805180820190915260018152600360fc1b602082015290565b8160005b811561229c578061228681612b8e565b91506122959050600a83612bbd565b9150612276565b6000816001600160401b038111156122b6576122b6612675565b6040519080825280601f01601f1916602001820160405280156122e0576020820181803683370190505b5090505b84156118d4576122f5600183612bd1565b9150612302600a86612be8565b61230d906030612b0b565b60f81b81838151811061232257612322612bfc565b60200101906001600160f81b031916908160001a905350612344600a86612bbd565b94506122e4565b600054610100900460ff166123725760405162461bcd60e51b81526004016103ca90612d69565b61125933611cdc565b61238481611de1565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6124235760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016103ca565b600080846001600160a01b03168460405161243e9190612e70565b600060405180830381855af49150503d8060008114612479576040519150601f19603f3d011682016040523d82523d6000602084013e61247e565b606091505b50915091506124a68282604051806060016040528060278152602001612f70602791396124af565b95945050505050565b606083156124be575081611be5565b8251156124ce5782518084602001fd5b8160405162461bcd60e51b81526004016103ca91906127d0565b6000602082840312156124fa57600080fd5b5035919050565b6001600160a01b038116811461046757600080fd5b60008060008060006080868803121561252e57600080fd5b853561253981612501565b9450602086013561254981612501565b93506040860135925060608601356001600160401b038082111561256c57600080fd5b818801915088601f83011261258057600080fd5b81358181111561258f57600080fd5b8960208285010111156125a157600080fd5b9699959850939650602001949392505050565b6000602082840312156125c657600080fd5b8135611be581612501565b600080604083850312156125e457600080fd5b8235915060208301356125f681612501565b809150509250929050565b6000806040838503121561261457600080fd5b823561261f81612501565b946020939093013593505050565b6000806000806080858703121561264357600080fd5b843561264e81612501565b935060208501359250604085013561266581612501565b9396929550929360600135925050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561269e57600080fd5b82356126a981612501565b915060208301356001600160401b03808211156126c557600080fd5b818501915085601f8301126126d957600080fd5b8135818111156126eb576126eb612675565b604051601f8201601f19908116603f0116810190838211818310171561271357612713612675565b8160405282815288602084870101111561272c57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000806040838503121561276157600080fd5b82359150602083013580151581146125f657600080fd5b60005b8381101561279357818101518382015260200161277b565b83811115611ea25750506000910152565b600081518084526127bc816020860160208601612778565b601f01601f19169290920160200192915050565b602081526000611be560208301846127a4565b634e487b7160e01b600052602160045260246000fd5b815160a08201906004811061281e57634e487b7160e01b600052602160045260246000fd5b82526020838101516001600160401b0316908301526040808401511515908301526060808401516001600160a01b031690830152608092830151929091019190915290565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b656f776e65723d60d01b81526000825161291c816006850160208701612778565b9190910160060192915050565b667269675f69643d60c81b81526000835161294b816007850160208801612778565b6401030b732160dd1b6007918401918201526a73746172745f74696d653d60a81b600c8201528351612984816017840160208801612778565b01601701949350505050565b60018060a01b03841681528260208201526060604082015260006124a660608301846127a4565b600084516129c9818460208901612778565b8083019050600b60fa1b80825285516129e9816001850160208a01612778565b60019201918201528351612a04816002840160208801612778565b0160020195945050505050565b600060208284031215612a2357600080fd5b8151611be581612501565b68656e645f74696d653d60b81b815260008251612a52816009850160208701612778565b9190910160090192915050565b60008651612a71818460208b01612778565b8083019050600b60fa1b8082528751612a91816001850160208c01612778565b600192019182018190528651612aae816002850160208b01612778565b600292019182018190528551612acb816003850160208a01612778565b60039201918201528351612ae6816004840160208801612778565b01600401979650505050505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612b1e57612b1e612af5565b500190565b6001600160a01b03831681526040602082018190526000906118d4908301846127a4565b600060208284031215612b5957600080fd5b5051919050565b6000602760f81b8083528351612b7d816001860160208801612778565b600193019283015250600201919050565b600060018201612ba057612ba0612af5565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082612bcc57612bcc612ba7565b500490565b600082821015612be357612be3612af5565b500390565b600082612bf757612bf7612ba7565b500690565b634e487b7160e01b600052603260045260246000fd5b660102ba422a922960cd1b815260008251612c34816007850160208701612778565b9190910160070192915050565b6602aa82220aa22960cd1b815260008451612c63816007850160208901612778565b6401029a2aa160dd1b6007918401918201528451612c8881600c840160208901612778565b8451910190612c9e81600c840160208801612778565b01600c0195945050505050565b6b024a729a2a92a1024a72a27960a51b815260008451612cd281600c850160208901612778565b600560fb1b600c918401918201528451612cf381600d840160208901612778565b67052ac8298aa8aa6560c31b600d92909101918201528351612d1c816015840160208801612778565b602960f81b6015929091019182015260160195945050505050565b60008451612d49818460208901612778565b8083019050605f60f81b80825285516129e9816001850160208a01612778565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6c021a922a0aa22902a20a126229609d1b815260008451612ddc81600d850160208901612778565b605f60f81b600d918401918201528451612dfd81600e840160208901612778565b600560fb1b600e92909101918201528351612e1f81600f840160208801612778565b602960f81b600f929091019182015260100195945050505050565b6000816000190483118215151615612e5457612e54612af5565b500290565b600081612e6857612e68612af5565b506000190190565b60008251612e82818460208701612778565b919091019291505056fe7269675f69642c6f776e65722c70696c6f745f636f6e74726163742c70696c6f745f69642c73746172745f74696d65360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc696420696e7465676572207072696d617279206b65792c7269675f696420696e7465676572206e6f74206e756c6c2c6f776e65722074657874206e6f74206e756c6c2c70696c6f745f636f6e747261637420746578742c70696c6f745f696420696e74656765722c73746172745f74696d6520696e7465676572206e6f74206e756c6c2c656e645f74696d6520696e7465676572416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220f61075283da4e2ced15d4f534e53896cf772a854fc191549d54c442dd07e0f0464736f6c634300080f0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.