Contract 0x2DE0E71697B2B7B9591EcF0d6BF4F96D168F63EF

Contract Overview

Balance:
0 MATIC
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0xb1c450603576448f15e72a93a1046c13598cbe96cf145ee63bb49f152ba8c42c0x60a08060336397812023-03-27 17:47:0163 days 14 hrs ago0x4e27128cdef7a3cffdf800be3be6ee74639cb639 IN  Create: Ticket0 MATIC0.003047358789 1.627660013
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Ticket

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 15 : 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 2 of 15 : 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 3 of 15 : 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 4 of 15 : 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 5 of 15 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (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.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

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

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 6 of 15 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 the implementation's compatibility when performing 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 7 of 15 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @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 8 of 15 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 9 of 15 : 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 10 of 15 : 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 11 of 15 : IGateway.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import "./Utils.sol";

/**
 * @dev Interface of the Gateway Self External Calls.
 */
interface IGateway {
    function requestToRouter(
        uint256 routeAmount,
        string memory routeRecipient,
        bytes memory payload,
        string memory routerBridgeContract,
        uint256 gasLimit,
        bytes memory asmAddress
    ) external payable returns (uint64);

    function setDappMetadata(string memory feePayerAddress) external payable returns (uint64);

    function executeHandlerCalls(
        string memory sender,
        bytes[] memory handlers,
        bytes[] memory payloads,
        bool isAtomic
    ) external returns (bool[] memory, bytes[] memory);

    function requestToDest(
        Utils.RequestArgs memory requestArgs,
        Utils.AckType ackType,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        Utils.ContractCalls memory contractCalls
    ) external payable returns (uint64);

    function readQueryToDest(
        Utils.RequestArgs memory requestArgs,
        Utils.AckGasParams memory ackGasParams,
        Utils.DestinationChainParams memory destChainParams,
        Utils.ContractCalls memory contractCalls
    ) external payable returns (uint64);

    function requestToRouterDefaultFee() external view returns (uint256 fees);

    function requestToDestDefaultFee() external view returns (uint256 fees);
}

File 12 of 15 : Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

library Utils {
    // This is used purely to avoid stack too deep errors
    // represents everything about a given validator set
    struct ValsetArgs {
        // the validators in this set, represented by an Ethereum address
        address[] validators;
        // the powers of the given validators in the same order as above
        uint64[] powers;
        // the nonce of this validator set
        uint64 valsetNonce;
    }

    // This is being used purely to avoid stack too deep errors
    struct RouterRequestPayload {
        //route
        uint256 routeAmount;
        bytes routeRecipient;
        // the sender address
        string routerBridgeAddress;
        string relayerRouterAddress;
        bool isAtomic;
        uint64 chainTimestamp;
        uint64 expTimestamp;
        // The user contract address
        bytes asmAddress;
        bytes[] handlers;
        bytes[] payloads;
        uint64 outboundTxNonce;
    }

    struct AckGasParams {
        uint64 gasLimit;
        uint64 gasPrice;
    }

    struct InboundSourceInfo {
        uint256 routeAmount;
        string routeRecipient;
        uint64 eventNonce;
        uint64 srcChainType;
        string srcChainId;
    }

    struct SourceChainParams {
        uint64 crossTalkNonce;
        uint64 expTimestamp;
        bool isAtomicCalls;
        uint64 chainType;
        string chainId;
    }
    struct SourceParams {
        bytes caller;
        uint64 chainType;
        string chainId;
    }

    struct DestinationChainParams {
        uint64 gasLimit;
        uint64 gasPrice;
        uint64 destChainType;
        string destChainId;
        bytes asmAddress;
    }

    struct RequestArgs {
        uint64 expTimestamp;
        bool isAtomicCalls;
    }

    struct ContractCalls {
        bytes[] payloads;
        bytes[] destContractAddresses;
    }

    struct CrossTalkPayload {
        string relayerRouterAddress;
        bool isAtomic;
        uint64 eventIdentifier;
        uint64 chainTimestamp;
        uint64 expTimestamp;
        uint64 crossTalkNonce;
        bytes asmAddress;
        SourceParams sourceParams;
        ContractCalls contractCalls;
        bool isReadCall;
    }

    struct CrossTalkAckPayload {
        string relayerRouterAddress;
        uint64 crossTalkNonce;
        uint64 eventIdentifier;
        uint64 destChainType;
        string destChainId;
        bytes srcContractAddress;
        bool[] execFlags;
        bytes[] execData;
    }

    // This represents a validator signature
    struct Signature {
        uint8 v;
        bytes32 r;
        bytes32 s;
    }

    enum AckType {
        NO_ACK,
        ACK_ON_SUCCESS,
        ACK_ON_ERROR,
        ACK_ON_BOTH
    }

    error IncorrectCheckpoint();
    error InvalidValsetNonce(uint64 newNonce, uint64 currentNonce);
    error MalformedNewValidatorSet();
    error MalformedCurrentValidatorSet();
    error InsufficientPower(uint64 cumulativePower, uint64 powerThreshold);
    error InvalidSignature();
    // constants
    string constant MSG_PREFIX = "\x19Ethereum Signed Message:\n32";
    // The number of 'votes' required to execute a valset
    // update or batch execution, set to 2/3 of 2^32
    uint64 constant constantPowerThreshold = 2791728742;
}

File 13 of 15 : ILottery.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

interface ILottery {
    function enrollTicketContract(
        uint64 _chainType,
        string memory _chainId,
        address _contractAddress
    ) external;

    function addSLottery(uint256 reward) external;

    function addMLottery(uint256[] memory _rewards) external;

    function drawLuckyNumber() external;

    function claimLottery(uint64 _lotterId, uint256 _riderId) external;

    function processTicket(
        uint256 riderId,
        address sender,
        uint256 score,
        uint64 _lotteryId
    ) external;
}

File 14 of 15 : IRouterRiderERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.16;

interface IRouterRiderERC721 {
    struct RiderMetadata {
        address owner;
        bool riding;
        uint256 score;
        uint256 lastRideTime;
        uint256 lastRideStartTime;
        bytes32[5] last_five_chains;
        uint64[20] numberOfTimes;
        uint64 trackLast;
        uint64 noOfRides;
    }

    function updateTravelThresholds(
        uint64[5] memory _chainTravelThresholds,
        uint64[6] memory _ccTravelRangeScore
    ) external;

    function getRiderMetadata(
        uint256 riderId
    ) external view returns (RiderMetadata memory);

    function enrollRemoteContract(
        uint64 _chainType,
        string memory _chainId,
        address _contractAddress
    ) external;

    function mapChainContract(
        uint64[] memory _chainTypes,
        string[] memory _chainIds
    ) external;
}

File 15 of 15 : Ticket.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
pragma abicoder v2;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@routerprotocol/evm-gateway-contracts/contracts/IGateway.sol";
import "./interface/IRouterRiderERC721.sol";
import "./interface/ILottery.sol";

/**
 * @title Ticket
 * @author  Router Protocol
 * @notice this contract will be use for submitting ticket to lottery contract on dst chain by using their rider NFT
 * this will be deployed on each supported chain
 */

contract Ticket is
    Initializable,
    OwnableUpgradeable,
    UUPSUpgradeable,
    ReentrancyGuardUpgradeable
{
    /** 
        it will be emitted when user submitted ticket from src chain to dst chain
        * @param sender sender who submitted address
        * @param riderId this it tokenId of nft from which user participated in lottery
    */
    event SubmittingTicket(
        string srcChainId,
        uint64 srcChainType,
        address sender,
        uint256 riderId
    );

    /** 
        it will be emitted when user submitted ticket on same chain
        * @param sender sender who submitted address
        * @param riderId this it tokenId of nft from which user participated in lottery
    */
    event SubmittedTicketOnSameChain(
        address sender,
        uint256 riderId,
        uint64 lotteryId
    );

    /** 
        it will be emitted when ticket got submitted on dst chain
    */
    event TicketSubmitted(uint64 lotteryId, uint256 riderId);

    /**
     * @notice gateway contract address on this chain
     */
    address public gatewayContract;
    /**
     * @notice router rider contract on this chain
     */
    address public routerRiderAddress;
    /**
     * @notice gas limit for handleRequestFromSource on dst chain
     */
    uint64 public destGasLimit;

    /**
     * @notice chain type for chain on which lottery contract deployed
     */
    uint64 public lotteryChainType;

    /**
     * @notice chain type of this chain
     */
    uint64 public chainType;

    /**
     * @notice upper time limit for which handleCrossTalkAck on dst chain should be executed
     */
    uint64 public expiryTimestamp;
    /**
     * @notice chain id of this chain
     */
    string public chainId;
    /**
     * @notice lottery contract address on lottery chain
     */
    string lotteryContractEVMString;
    address public lotteryContractAddress;
    /**
     * @notice chain id for chain on which lottery contract deployed
     */
    string public lotteryChainId;
    IGateway gateway;

    /**
     * initializer for this contract
     * @param gatewayAddress gateway contract address on this chain
     * @param _routerRiderAddress router rider contract on this chain
     * @param _destGasLimit gas limit for handleRequestFromSource on dst chain
     * @param _chainId chain id of this chain
     * @param _chainType chain type of this chain
     * @param _expiryTimestamp upper time limit for which handleCrossTalkAck on dst chain should be executed
     */
    function initialize(
        address payable gatewayAddress,
        address _routerRiderAddress,
        uint64 _destGasLimit,
        string memory _chainId,
        uint64 _chainType,
        uint64 _expiryTimestamp
    ) public initializer {
        __Ownable_init();
        __UUPSUpgradeable_init();

        gatewayContract = gatewayAddress;
        destGasLimit = _destGasLimit;
        chainId = _chainId;
        chainType = _chainType;
        routerRiderAddress = _routerRiderAddress;
        if (_expiryTimestamp == 0) expiryTimestamp = type(uint64).max;
        else expiryTimestamp = _expiryTimestamp;

        gateway = IGateway(gatewayContract);
    }

    function isRouterChain() internal view returns (bool) {
        return
            keccak256(abi.encodePacked(lotteryChainId)) ==
            keccak256(abi.encodePacked(chainId)) &&
            lotteryChainType == chainType;
    }

    function setFeePayer(string memory feePayer) public payable onlyOwner {
        require(!isRouterChain(), "daap itself will pay on router chain");
        gateway.setDappMetadata{value: msg.value}(feePayer);
    }

    /**
     * this will be used to submit ticket on lottery contract
     * @param riderId token id of rider nft
     */
    function SubmitTicket(
        uint256 riderId,
        uint64 _lotteryId
    ) public payable nonReentrant {
        IRouterRiderERC721.RiderMetadata
            memory riderMetadata = IRouterRiderERC721(routerRiderAddress)
                .getRiderMetadata(riderId);
        require(riderMetadata.owner == msg.sender, "caller not owner of Rider");

        // lottery contract exist on this chain itself
        if (isRouterChain()) {
            require(msg.value == 0, "fee not required");
            ILottery(lotteryContractAddress).processTicket(
                riderId,
                msg.sender,
                riderMetadata.score,
                _lotteryId
            );

            emit SubmittedTicketOnSameChain(msg.sender, riderId, _lotteryId);
            return;
        }

        bytes memory payload = abi.encode(
            riderId,
            msg.sender,
            riderMetadata.score,
            _lotteryId
        );

        uint256 routeAmount = 0; // TODO: ?
        string memory routeRecipient = "0x"; // TODO: ?

        // ACK not required in this case
        gateway.requestToRouter{value: msg.value}(
            routeAmount,
            routeRecipient,
            payload,
            lotteryContractEVMString,
            destGasLimit,
            "0x"
        );
        emit SubmittingTicket(chainId, chainType, msg.sender, riderId);
    }

    /**
     * @notice it will be use to map lottery contract on each chain to lottery contract present on lottery chain
     * @param _lotteryContractEVMString[string hex] __lotteryContractAddress[address] contract address of lottery contract
     * @param _chainType chaintype of chain on which lottery contract deployed
     * @param _chainId chainid of chain on which lottery contract deployed
     */
    function enrollLotteryContract(
        string memory _lotteryContractEVMString,
        address _lotteryContractAddress,
        uint64 _chainType,
        string memory _chainId
    ) external onlyOwner {
        lotteryContractEVMString = _lotteryContractEVMString;
        lotteryChainId = _chainId;
        lotteryChainType = _chainType;
        lotteryContractAddress = _lotteryContractAddress;
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal virtual override {}

    receive() external payable {}
}

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

Contract ABI

[{"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":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"lotteryId","type":"uint64"}],"name":"SubmittedTicketOnSameChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"srcChainId","type":"string"},{"indexed":false,"internalType":"uint64","name":"srcChainType","type":"uint64"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"}],"name":"SubmittingTicket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"lotteryId","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"riderId","type":"uint256"}],"name":"TicketSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"uint256","name":"riderId","type":"uint256"},{"internalType":"uint64","name":"_lotteryId","type":"uint64"}],"name":"SubmitTicket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainType","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"destGasLimit","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_lotteryContractEVMString","type":"string"},{"internalType":"address","name":"_lotteryContractAddress","type":"address"},{"internalType":"uint64","name":"_chainType","type":"uint64"},{"internalType":"string","name":"_chainId","type":"string"}],"name":"enrollLotteryContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"expiryTimestamp","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gatewayContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"gatewayAddress","type":"address"},{"internalType":"address","name":"_routerRiderAddress","type":"address"},{"internalType":"uint64","name":"_destGasLimit","type":"uint64"},{"internalType":"string","name":"_chainId","type":"string"},{"internalType":"uint64","name":"_chainType","type":"uint64"},{"internalType":"uint64","name":"_expiryTimestamp","type":"uint64"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lotteryChainId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lotteryChainType","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lotteryContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"routerRiderAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"feePayer","type":"string"}],"name":"setFeePayer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","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"},{"stateMutability":"payable","type":"receive"}]

60a0806040523461003157306080526120e4908161003782396080518181816109ed01528181610aeb0152610e480152f35b600080fdfe60406080815260049081361015610020575b5050361561001e57600080fd5b005b600091823560e01c9081630d0a61b81461111e5781631d3ea11e146110f35781633659cfe614610e215781633b397af514610df857816345b33c7f14610dce5781634f1ef28614610a9a57816352d1902d146109d7578163575c891314610950578163715018a6146108f05781638da5cb5b146108c75781639a8a059214610806578163ade6e2aa146107db578163b4514437146107b3578163e0ad6eb2146103dd578163e448ab81146102bf578163eb0cde1d14610296578163f2fde38b1461020057508063f6cc782c146101d85763fe4870cb0361001157346101d457816003193601126101d457805190826101019081549061011e82611550565b808652926001928084169081156101a9575060011461015f575b61015b8686610149828b0383611478565b5191829160208352602083019061158a565b0390f35b8152945060008051602061208f8339815191525b8286106101915750505061014982602061015b958201019438610138565b80546020878701810191909152909501948101610173565b905061015b97508693506020925061014994915060ff191682840152151560051b8201019438610138565b5080fd5b50346101d457816003193601126101d45760fc5490516001600160a01b039091168152602090f35b9050346102925760203660031901126102925761021b611524565b916102246115ca565b6001600160a01b03831615610240578361023d84611622565b80f35b906020608492519162461bcd60e51b8352820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152fd5b8280fd5b5050346101d457816003193601126101d45760fb5490516001600160a01b039091168152602090f35b83602084366003190182136102925783356001600160401b0381116103d9576102eb90369086016114f0565b936102f46115ca565b6102fc611875565b61038c5761010254825163778ae5ed60e11b815291820184905293949093839185916001600160a01b0316908290819061033a90602483019061158a565b039134905af19081156103835750610350578280f35b81813d831161037c575b6103648183611478565b810103126101d45761037590611861565b5081808280f35b503d61035a565b513d85823e3d90fd5b82608492519162461bcd60e51b83528201526024808201527f6461617020697473656c662077696c6c20706179206f6e20726f7574657220636044820152633430b4b760e11b6064820152fd5b8380fd5b8383346101d45760c03660031901126101d45782356001600160a01b03818116918290036103d95761040d61150e565b9161041661153a565b916001600160401b036064358181116107af576104369036908a016114f0565b946084359180831683036107ab5760a43590808216908183036107a7578a549b60088d901c60ff161598898e81610799575b50801561077a575b15610720576104bd60ff8e9f9e8c9d9e9f60019e8f8419831617835561070f575b506104aa82825460081c166104a581611801565b611801565b6104b333611622565b5460081c16611801565b6bffffffffffffffffffffffff60a01b988960fb54161760fb5560fc54906001600160401b0360a01b9060a01b16906001600160401b0360a01b19161760fc558a519182116106fc575061051260fe54611550565b601f81116106a6575b50808c60209b8c91601f8411600114610637579261062c575b5050600019600383901b1c191690891b1760fe555b8467ffffffffffffffff60401b60fd54958c1b16938467ffffffffffffffff60401b1987161760fd55168660fc54161760fc55156000146105f657505060fd805467ffffffffffffffff60801b191667ffffffffffffffff60801b179055505b60fb5416610102918254161790556105bf578380f35b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989261ff0019855416855551908152a18180808380f35b6001600160401b0360801b9060801b169177ffffffffffffffffffffffffffffffff00000000000000001916171760fd556105a9565b015190508d80610534565b60fe81528c945060008051602061206f833981519152929190601f198516908f5b82821061068f5750508411610676575b505050811b0160fe55610549565b015160001960f88460031b161c191690558d8080610668565b8385015186558f979095019493840193018f610658565b60fe8d5260008051602061206f833981519152601f830160051c810191602084106106f2575b601f0160051c01908a908e5b8382106106e75750505061051b565b8155018a908e6106d8565b90915081906106cc565b634e487b7160e01b8d526041905260248cfd5b61ffff191661010117815538610491565b8b5162461bcd60e51b8152602081840152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b158e8161078b575b50610470565b6001915060ff16148e610785565b6001915060ff16108e610468565b8a80fd5b8880fd5b8780fd5b5050346101d457816003193601126101d4576020906001600160401b0360fd54169051908152f35b5050346101d457816003193601126101d4576020906001600160401b0360fd5460801c169051908152f35b5050346101d457816003193601126101d4578051908260fe5461082881611550565b8085529160019180831690811561089f5750600114610854575b5050506101498261015b940383611478565b945060fe855260008051602061206f8339815191525b8286106108875750505061014982602061015b9582010194610842565b8054602087870181019190915290950194810161086a565b61015b97508693506020925061014994915060ff191682840152151560051b82010194610842565b5050346101d457816003193601126101d45760335490516001600160a01b039091168152602090f35b833461094d578060031936011261094d576109096115ca565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b839150826003193601126101d457602435906001600160401b038216820361029257600260c95414610994579061098c91600260c955356119ef565b600160c95580f35b606490602085519162461bcd60e51b8352820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b9050823461094d578060031936011261094d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610a32576020825160008051602061204f8339815191528152f35b6020608492519162461bcd60e51b8352820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152fd5b839150826003193601126101d457610ab0611524565b906024356001600160401b0381116103d957366023820112156103d957610ae090369060248185013591016114b4565b936001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169190610b1a3084141561166b565b610b3760008051602061204f8339815191529382855416146116cc565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610b70575050505061023d91925061172d565b849193959294168351946352d1902d60e01b865260209586818981865afa859181610d9b575b50610bf557855162461bcd60e51b8152808901889052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b969192939603610d4657610c088361172d565b8351917fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8780a2865115801590610d3e575b610c49575b5050505050905080f35b823b15610cef575050928085610cd095858398519201905af43d15610cdc57660819985a5b195960ca1b3d92610c7e84611499565b93610c8b82519586611478565b84523d878686013e5b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c815195610cc187611447565b602787528601528401526117bd565b50808280808080610c3f565b660819985a5b195960ca1b606092610c94565b62461bcd60e51b82528101849052602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608490fd5b506001610c3a565b835162461bcd60e51b8152908101859052602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b9091508781813d8311610dc7575b610db38183611478565b81010312610dc35751908a610b96565b8580fd5b503d610da9565b5050346101d457816003193601126101d4576101005490516001600160a01b039091168152602090f35b5050346101d457816003193601126101d45760fd548151911c6001600160401b03168152602090f35b905034610292576020806003193601126103d957610e3d611524565b926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116610e753082141561166b565b610e9260008051602061204f8339815191529183835416146116cc565b825190848201928284106001600160401b038511176110e0578385528883527f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615610eeb575050505050505061023d9061172d565b879894959697169085516352d1902d60e01b815287818a81865afa8691816110ad575b50610f6d57865162461bcd60e51b8152808a01899052602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b9791929394970361105857610f818861172d565b8451917fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8880a2825115801590611051575b610fc3575b505050505050905080f35b873b156110025750509380958192610ff59651915af43d15610cdc57660819985a5b195960ca1b3d92610c7e84611499565b5080388080808080610fb8565b62461bcd60e51b82528101859052602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608490fd5b5086610fb3565b845162461bcd60e51b8152908101869052602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b9091508881813d83116110d9575b6110c58183611478565b810103126110d557519038610f0e565b8680fd5b503d6110bb565b634e487b7160e01b895260418752602489fd5b5050346101d457816003193601126101d4576020906001600160401b0360fc5460a01c169051908152f35b8390346101d45760803660031901126101d4576001600160401b0381358181116103d95761114f90369084016114f0565b9161115861150e565b9261116161153a565b916064358481116110d55761117990369083016114f0565b916111826115ca565b8051858111611434578061119760ff54611550565b92601f938481116113c8575b50602090848311600114611345578a9261133a575b50508160011b916000199060031b1c19161760ff555b82519185831161132757508190610101936111e98554611550565b8281116112cb575b50602091831160011461125c578892611251575b50508160011b916000199060031b1c19161790555b166001600160401b031960fd54161760fd556101009060018060a01b03166bffffffffffffffffffffffff60a01b82541617905580f35b015190508780611205565b84895260008051602061208f8339815191529250601f198416895b8181106112b3575090846001959493921061129a575b505050811b01905561121a565b015160001960f88460031b161c1916905587808061128d565b92936020600181928786015181550195019301611277565b9091925084895260008051602061208f8339815191528380860160051c8201926020871061131e575b94869594939291940160051c01905b81811061131057506111f1565b8a8155859450600101611303565b925081926112f4565b634e487b7160e01b885260419052602487fd5b0151905089806111b8565b60ff8b527fe08ec2af2cfc251225e1968fd6ca21e4044f129bffa95bac3503be8bdb30a3679250601f1984168b5b8181106113b05750908460019594939210611397575b505050811b0160ff556111ce565b015160001960f88460031b161c19169055898080611389565b92936020600181928786015181550195019301611373565b90915060ff8a527fe08ec2af2cfc251225e1968fd6ca21e4044f129bffa95bac3503be8bdb30a3678480850160051c8201926020861061142b575b9085949392910160051c01905b81811061141d57506111a3565b8b8155849350600101611410565b92508192611403565b634e487b7160e01b885260418352602488fd5b606081019081106001600160401b0382111761146257604052565b634e487b7160e01b600052604160045260246000fd5b90601f801991011681019081106001600160401b0382111761146257604052565b6001600160401b03811161146257601f01601f191660200190565b9291926114c082611499565b916114ce6040519384611478565b8294818452818301116114eb578281602093846000960137010152565b600080fd5b9080601f830112156114eb5781602061150b933591016114b4565b90565b602435906001600160a01b03821682036114eb57565b600435906001600160a01b03821682036114eb57565b604435906001600160401b03821682036114eb57565b90600182811c92168015611580575b602083101461156a57565b634e487b7160e01b600052602260045260246000fd5b91607f169161155f565b919082519283825260005b8481106115b6575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201611595565b6033546001600160a01b031633036115de57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b1561167257565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156116d357565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b803b156117625760008051602061204f83398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b909190156117c9575090565b8151156117d95750805190602001fd5b60405162461bcd60e51b8152602060048201529081906117fd90602483019061158a565b0390fd5b1561180857565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b51906001600160401b03821682036114eb57565b604051602080820191600092816101019485549561189287611550565b906001978789821691826000146119d657505060011461198f575b505003916118c3601f1993848101835282611478565b5190209260405191828481019460009360fe54906118e082611550565b91818116908115611974575060011461192b575b5050506119079203908101835282611478565b51902014806119135790565b5060fd546001600160401b03808260401c1691161490565b60fe600090815291955060008051602061206f8339815191525b86831061195e57505050611907938201019238806118f4565b8054888401850152879450918301918101611945565b60ff19168952505080151502820101925061190738806118f4565b86925060005260008051602061208f833981519152876000915b8383106119bd5750505082010138806118ad565b80548884018601528795508894909201918991016119a9565b925093505060ff191684528015150282010138806118ad565b60fc54604051639bd2954960e01b8152600480820184905260249593946000936001600160a01b03939061040090819083908b90829089165afa918215612043578692611ebc575b5050838151163303611e7957611a4b611875565b611d4c57604090810151815160208101899052339281019290925260608201526001600160401b03919091166080808301919091528152611a8d60a082611478565b60405192604084018481106001600160401b03821117611d385791611af2611b04928798999a946040526002875261060f60f31b602088015261010254169560c060fc54956040519a8b98636418cb8960e01b8a5289015287015260c486019061158a565b8481036003190160448601529061158a565b82810360031901606484015260ff5460009291611b2082611550565b8082529160018116908115611d135750600114611cb1575b50506040602094926001600160401b03859360a01c16608484015261060f60f31b8684830392600319840160a4870152600281520152019134905af18015611ca457611c69575b50506001600160401b0360fd5460401c1691604051906080825260009360fe54611ba881611550565b90816080860152600181169081600014611c475750600114611c01575b509382917fa350efcc791c1ead4b2333dd0f98c16b794f0fd18c5af7a40ca706693a8f705f9495602084015233604084015260608301520390a1565b60fe600090815291955060008051602061206f8339815191525b818310611c30575050820160a0019382611bc5565b805460a08487010152602090920191600101611c1b565b60ff191660a08681019190915291151560051b85019091019550839050611bc5565b6020823d602011611c9c575b81611c8260209383611478565b8101031261094d5750611c9490611861565b503880611b7f565b3d9150611c75565b50604051903d90823e3d90fd5b94925060ff6000527fe08ec2af2cfc251225e1968fd6ca21e4044f129bffa95bac3503be8bdb30a367906000915b818310611cf757509294016020019150604083611b38565b8054602088850181019190915289965090920191600101611cdf565b60ff191660208381019190915292151560051b90910190910192506040905083611b38565b88604185634e487b7160e01b600052526000fd5b9094969234611e43576040906101005416910151813b15611e3f576040805163221ba49d60e21b8152808501898152336020820152918201929092526001600160401b038716606082015290939291859185919082908490829060800103925af18015611e3457611dfe575b505050507f19a90bbc3719b22a42da9f1173aa881b034ca5ca1dfd5612e885d26c0c38397a916001600160401b03606092604051923384526020840152166040820152a1565b6001600160401b038311611e2357505060405282906001600160401b03908390611db8565b634e487b7160e01b84526041905282fd5b6040513d86823e3d90fd5b8480fd5b60405162461bcd60e51b81526020818501526010818601526f199959481b9bdd081c995c5d5a5c995960821b6044820152606490fd5b60405162461bcd60e51b81526020818501526019818a01527f63616c6c6572206e6f74206f776e6572206f66205269646572000000000000006044820152606490fd5b908092503d831161203c575b611ed28183611478565b81019181830312610dc357604051916001600160401b0361012084018181118582101761202a57604052825187811681036107ab578452602080840151801515810361201257818601526040840151604086015260608401516060860152608084015160808601528260bf850112156107ab5760405160a08101818110848211176120005760405280610140860191858311612026578360a08801915b8483106120165750505060a08701528361015f8601121561201257604051926102808401908111848210176120005760405282906103c086019485116107a757905b848210611fe95750505091611fd16103e092611fdc9460c0870152611861565b60e085015201611861565b6101008201523880611a37565b828091611ff584611861565b815201910190611fb1565b634e487b7160e01b8b52604189528d8bfd5b8980fd5b8251815291810191859101611f6f565b8b80fd5b634e487b7160e01b8952604187528b89fd5b503d611ec8565b6040513d88823e3d90fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54075df80ec1ae6ac9100e1fd0ebf3246c17f5c933137af392011f4c5f61513a109ea3cebb188b9c1b9fc5bb3920be60dfdc8699098dff92f3d80daaca747689a264697066735822122085d9e8f91adb4723576fd9d09cd696afccc7d15532544f0c309dc4a4495d4d2764736f6c63430008120033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading