Contract 0x60a75B5B7DCa50ad7E0a27802Dc0f0e676006679 8

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x566dd13c457ef02f3c2f874c91623dcdd829a7b3e4a263d77dea6600ec0eeb0e0x60806040165940492022-12-10 2:11:17299 days 1 hr ago0x54812dbab593674cd4f1216264895be48b55c5e3 IN  Create: CaskSubscriptionPlans0 CELO0.0011526645
[ Download CSV Export 
Parent Txn Hash Block From To Value
Index Block
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CaskSubscriptionPlans

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 15 : CaskSubscriptionPlans.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";

import "@opengsn/contracts/src/BaseRelayRecipient.sol";


import "../interfaces/ICaskSubscriptionPlans.sol";

contract CaskSubscriptionPlans is
ICaskSubscriptionPlans,
BaseRelayRecipient,
OwnableUpgradeable,
PausableUpgradeable
{
    using ECDSA for bytes32;

    /** @dev Address of subscription manager. */
    address public subscriptionManager;

    /** @dev Map for provider to profile info. */
    mapping(address => Provider) internal providerProfiles;

    /** @dev Map for current plan status. */
    // provider->planId => Plan
    mapping(address => mapping(uint32 => PlanStatus)) internal planStatus;
    mapping(address => mapping(uint32 => uint32)) internal planEol;

    /** @dev Maps for discounts. */
    mapping(address => mapping(uint32 => mapping(bytes32 => uint256))) internal discountRedemptions;

    /** @dev Address of subscriptions contract. */
    address public subscriptions;

    modifier onlyManager() {
        require(_msgSender() == subscriptionManager, "!AUTH");
        _;
    }

    modifier onlySubscriptions() {
        require(_msgSender() == subscriptions, "!AUTH");
        _;
    }

    function initialize() public initializer {
        __Ownable_init();
        __Pausable_init();

        subscriptions = address(0);
    }
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() initializer {}

    function versionRecipient() public pure override returns(string memory) { return "2.2.0"; }

    function _msgSender() internal view override(ContextUpgradeable, BaseRelayRecipient)
    returns (address sender) {
        sender = BaseRelayRecipient._msgSender();
    }

    function _msgData() internal view override(ContextUpgradeable, BaseRelayRecipient)
    returns (bytes calldata) {
        return BaseRelayRecipient._msgData();
    }

    function setProviderProfile(
        address _paymentAddress,
        string calldata _cid,
        uint256 _nonce
    ) external override {
        Provider storage profile = providerProfiles[_msgSender()];
        if (profile.nonce > 0) {
            require(_nonce > profile.nonce, "!NONCE");
        }
        profile.paymentAddress = _paymentAddress;
        profile.cid = _cid;
        profile.nonce = _nonce;

        emit ProviderSetProfile(_msgSender(), _paymentAddress, _nonce, _cid);
    }

    function getProviderProfile(
        address _provider
    ) external override view returns(Provider memory) {
        return providerProfiles[_provider];
    }

    function verifyPlan(
        bytes32 _planData,
        bytes32 _merkleRoot,
        bytes32[] calldata _merkleProof
    ) external override pure returns(bool) {
        return MerkleProof.verify(_merkleProof, _merkleRoot, keccak256(abi.encode(_planData)));
    }

    function getDiscountRedemptions(
        address _provider,
        uint32 _planId,
        bytes32 _discountId
    ) external view override returns(uint256) {
        return discountRedemptions[_provider][_planId][_discountId];
    }

    function verifyDiscount(
        address _consumer,
        address _provider,
        uint32 _planId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) public view override returns(bytes32) {
        if (_discountProof.length < 3 || _discountProof[0] == 0) {
            return 0;
        }

        DiscountType discountType = _parseDiscountType(_discountProof[1]);

        if (discountType == DiscountType.Code) {
            return _verifyCodeDiscount(_provider, _planId, _discountProof);
        } else if (discountType == DiscountType.ERC20) {
            return _verifyErc20Discount(_consumer, _provider, _planId, _discountProof);
        } else {
            return 0;
        }
    }

    function verifyAndConsumeDiscount(
        address _consumer,
        address _provider,
        uint32 _planId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) external override onlySubscriptions returns(bytes32) {
        bytes32 discountId = verifyDiscount(_consumer, _provider, _planId, _discountProof);
        if (discountId > 0) {
            Discount memory discountInfo = _parseDiscountData(_discountProof[1]);
            discountRedemptions[_provider][discountInfo.planId][discountId] += 1;
        }
        return discountId;
    }

    function _verifyCodeDiscount(
        address _provider,
        uint32 _planId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) internal view returns(bytes32) {
        if (_discountProof.length < 3 || _discountProof[0] == 0) {
            return 0;
        }

        bytes32 discountId = keccak256(abi.encode(_discountProof[0]));

        if (_verifyDiscountProof(discountId, _discountProof) &&
            _verifyDiscountData(discountId, _provider, _planId, _discountProof[1]))
        {
            return discountId;
        }
        return 0;
    }

    function _verifyErc20Discount(
        address _consumer,
        address _provider,
        uint32 _planId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) internal view returns(bytes32) {
        if (_discountProof.length < 3 || _discountProof[0] == 0) {
            return 0;
        }

        bytes32 discountId = _discountProof[0];

        if (_verifyDiscountProof(discountId, _discountProof) &&
            erc20DiscountCurrentlyApplies(_consumer, discountId) &&
            _verifyDiscountData(discountId, _provider, _planId, _discountProof[1]))
        {
            return discountId;
        }
        return 0;
    }

    function _verifyDiscountProof(
        bytes32 _discountId,
        bytes32[] calldata _discountProof // [discountValidator, discountData, merkleRoot, merkleProof...]
    ) internal pure returns(bool) {
        if (_discountProof.length < 3 || _discountProof[0] == 0) {
            return false;
        }

        // its possible to have an empty merkleProof if the merkleRoot IS the leaf
        bytes32[] memory merkleProof = new bytes32[](0);
        if (_discountProof.length >= 4) {
            merkleProof = _discountProof[3:];
        }

        return MerkleProof.verify(merkleProof, _discountProof[2],
            keccak256(abi.encode(_discountId, _discountProof[1])));
    }

    function _verifyDiscountData(
        bytes32 _discountId,
        address _provider,
        uint32 _planId,
        bytes32 _discountData
    ) internal view returns(bool) {
        Discount memory discountInfo = _parseDiscountData(_discountData);

        return
            (discountInfo.planId == 0 || discountInfo.planId == _planId) &&
            (discountInfo.maxRedemptions == 0 ||
                discountRedemptions[_provider][discountInfo.planId][_discountId] < discountInfo.maxRedemptions) &&
            (discountInfo.validAfter == 0 || discountInfo.validAfter <= uint32(block.timestamp)) &&
            (discountInfo.expiresAt == 0 || discountInfo.expiresAt > uint32(block.timestamp));
    }

    function erc20DiscountCurrentlyApplies(
        address _consumer,
        bytes32 _discountValidator
    ) public view override returns(bool) {
        address token = address(bytes20(_discountValidator));
        uint8 decimals = uint8(bytes1(_discountValidator << 160));

        if (decimals == 255) {
            try IERC20Metadata(token).decimals() returns (uint8 detectedDecimals) {
                decimals = detectedDecimals;
            } catch (bytes memory) {
                return false;
            }
        }

        try IERC20Metadata(token).balanceOf(_consumer) returns (uint256 balance) {
            if (decimals > 0) {
                balance = balance / uint256(10 ** decimals);
            }
            uint64 minBalance = uint64(bytes8(_discountValidator << 192));

            return balance >= minBalance;
        } catch (bytes memory) {
            return false;
        }
    }

    function verifyProviderSignature(
        address _provider,
        uint256 _nonce,
        bytes32 _planMerkleRoot,
        bytes32 _discountMerkleRoot,
        bytes memory _providerSignature
    ) public view override returns (bool) {
        bytes32 signedMessageHash = keccak256(abi.encode(_nonce, _planMerkleRoot, _discountMerkleRoot))
            .toEthSignedMessageHash();
        if (_providerSignature.length == 0) {
            bytes4 result = IERC1271(_provider).isValidSignature(signedMessageHash, _providerSignature);
            return result == IERC1271.isValidSignature.selector && _nonce == providerProfiles[_provider].nonce;
        } else {
            address recovered = signedMessageHash.recover(_providerSignature);
            return recovered == _provider && _nonce == providerProfiles[_provider].nonce;
        }
    }

    function verifyNetworkData(
        address _network,
        bytes32 _networkData,
        bytes memory _networkSignature
    ) public view override returns (bool) {
        bytes32 signedMessageHash = keccak256(abi.encode(_networkData)).toEthSignedMessageHash();
        if (_networkSignature.length == 0) {
            bytes4 result = IERC1271(_network).isValidSignature(signedMessageHash, _networkSignature);
            return result == IERC1271.isValidSignature.selector;
        } else {
            address recovered = signedMessageHash.recover(_networkSignature);
            return recovered == _network;
        }
    }

    function getPlanStatus(
        address _provider,
        uint32 _planId
    ) external view returns (PlanStatus) {
        return planStatus[_provider][_planId];
    }

    function getPlanEOL(
        address _provider,
        uint32 _planId
    ) external view returns (uint32) {
        return planEol[_provider][_planId];
    }

    function disablePlan(
        uint32 _planId
    ) external override {
        require(planStatus[_msgSender()][_planId] == PlanStatus.Enabled, "!NOT_ENABLED");

        planStatus[_msgSender()][_planId] = PlanStatus.Disabled;

        emit PlanDisabled(_msgSender(), _planId);
    }

    function enablePlan(
        uint32 _planId
    ) external override {
        require(planStatus[_msgSender()][_planId] == PlanStatus.Disabled, "!NOT_DISABLED");

        planStatus[_msgSender()][_planId] = PlanStatus.Enabled;

        emit PlanEnabled(_msgSender(), _planId);
    }

    function retirePlan(
        uint32 _planId,
        uint32 _retireAt
    ) external override {
        planStatus[_msgSender()][_planId] = PlanStatus.EndOfLife;
        planEol[_msgSender()][_planId] = _retireAt;

        emit PlanRetired(_msgSender(), _planId, _retireAt);
    }

    function _parseDiscountType(
        bytes32 _discountData
    ) internal pure returns(DiscountType) {
        return DiscountType(uint8(bytes1(_discountData << 248)));
    }

    function _parseDiscountData(
        bytes32 _discountData
    ) internal pure returns(Discount memory) {
        bytes1 options = bytes1(_discountData << 240);
        return Discount({
        value: uint256(_discountData >> 160),
        validAfter: uint32(bytes4(_discountData << 96)),
        expiresAt: uint32(bytes4(_discountData << 128)),
        maxRedemptions: uint32(bytes4(_discountData << 160)),
        planId: uint32(bytes4(_discountData << 192)),
        applyPeriods: uint16(bytes2(_discountData << 224)),
        discountType: DiscountType(uint8(bytes1(_discountData << 248))),
        isFixed: options & 0x01 == 0x01
        });
    }


    /************************** ADMIN FUNCTIONS **************************/

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function setManager(
        address _subscriptionManager
    ) external onlyOwner {
        subscriptionManager = _subscriptionManager;
    }

    function setSubscriptions(
        address _subscriptions
    ) external onlyOwner {
        subscriptions = _subscriptions;
    }

    function setTrustedForwarder(
        address _forwarder
    ) external onlyOwner {
        _setTrustedForwarder(_forwarder);
    }

}

File 2 of 15 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        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);
    }
    uint256[49] private __gap;
}

File 3 of 15 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 4 of 15 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 5 of 15 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            }
        }
        return computedHash;
    }
}

File 6 of 15 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 7 of 15 : IERC1271.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 8 of 15 : BaseRelayRecipient.sol
// SPDX-License-Identifier: MIT
// solhint-disable no-inline-assembly
pragma solidity >=0.6.9;

import "./interfaces/IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {

    /*
     * Forwarder singleton we accept calls from
     */
    address private _trustedForwarder;

    function trustedForwarder() public virtual view returns (address){
        return _trustedForwarder;
    }

    function _setTrustedForwarder(address _forwarder) internal {
        _trustedForwarder = _forwarder;
    }

    function isTrustedForwarder(address forwarder) public virtual override view returns(bool) {
        return forwarder == _trustedForwarder;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal override virtual view returns (address ret) {
        if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            ret = msg.sender;
        }
    }

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise (if the call was made directly and not through the forwarder), return `msg.data`
     * should be used in the contract instead of msg.data, where this difference matters.
     */
    function _msgData() internal override virtual view returns (bytes calldata ret) {
        if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) {
            return msg.data[0:msg.data.length-20];
        } else {
            return msg.data;
        }
    }
}

File 9 of 15 : ICaskSubscriptionPlans.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ICaskSubscriptionPlans {

    enum PlanStatus {
        Enabled,
        Disabled,
        EndOfLife
    }

    enum DiscountType {
        None,
        Code,
        ERC20
    }

    struct Discount {
        uint256 value;
        uint32 validAfter;
        uint32 expiresAt;
        uint32 maxRedemptions;
        uint32 planId;
        uint16 applyPeriods;
        DiscountType discountType;
        bool isFixed;
    }

    struct Provider {
        address paymentAddress;
        uint256 nonce;
        string cid;
    }

    function setProviderProfile(address _paymentAddress, string calldata _cid, uint256 _nonce) external;

    function getProviderProfile(address _provider) external view returns(Provider memory);

    function getPlanStatus(address _provider, uint32 _planId) external view returns (PlanStatus);

    function getPlanEOL(address _provider, uint32 _planId) external view returns (uint32);

    function disablePlan(uint32 _planId) external;

    function enablePlan(uint32 _planId) external;

    function retirePlan(uint32 _planId, uint32 _retireAt) external;

    function verifyPlan(bytes32 _planData, bytes32 _merkleRoot,
        bytes32[] calldata _merkleProof) external view returns(bool);

    function getDiscountRedemptions(address _provider, uint32 _planId,
        bytes32 _discountId) external view returns(uint256);

    function verifyAndConsumeDiscount(address _consumer, address _provider, uint32 _planId,
        bytes32[] calldata _discountProof) external returns(bytes32);

    function verifyDiscount(address _consumer, address _provider, uint32 _planId,
        bytes32[] calldata _discountProof) external returns(bytes32);

    function erc20DiscountCurrentlyApplies(address _consumer, bytes32 _discountValidator) external returns(bool);

    function verifyProviderSignature(address _provider, uint256 _nonce, bytes32 _planMerkleRoot,
        bytes32 _discountMerkleRoot, bytes memory _providerSignature) external view returns (bool);

    function verifyNetworkData(address _network, bytes32 _networkData,
        bytes memory _networkSignature) external view returns (bool);


    /** @dev Emitted when `provider` sets their profile info */
    event ProviderSetProfile(address indexed provider, address indexed paymentAddress, uint256 nonce, string cid);

    /** @dev Emitted when `provider` disables a subscription plan */
    event PlanDisabled(address indexed provider, uint32 indexed planId);

    /** @dev Emitted when `provider` enables a subscription plan */
    event PlanEnabled(address indexed provider, uint32 indexed planId);

    /** @dev Emitted when `provider` end-of-lifes a subscription plan */
    event PlanRetired(address indexed provider, uint32 indexed planId, uint32 retireAt);

}

File 10 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 {
        __Context_init_unchained();
    }

    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;
    }
    uint256[50] private __gap;
}

File 11 of 15 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

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 a proxied contract can't have 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.
 *
 * 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 initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 12 of 15 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 13 of 15 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 14 of 15 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

File 15 of 15 : IRelayRecipient.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {

    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public virtual view returns(bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal virtual view returns (address);

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise (if the call was made directly and not through the forwarder), return `msg.data`
     * should be used in the contract instead of msg.data, where this difference matters.
     */
    function _msgData() internal virtual view returns (bytes calldata);

    function versionRecipient() external virtual view returns (string memory);
}

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

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"PlanDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint32","name":"planId","type":"uint32"}],"name":"PlanEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"uint32","name":"planId","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"retireAt","type":"uint32"}],"name":"PlanRetired","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":true,"internalType":"address","name":"paymentAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"indexed":false,"internalType":"string","name":"cid","type":"string"}],"name":"ProviderSetProfile","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"disablePlan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"enablePlan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"bytes32","name":"_discountValidator","type":"bytes32"}],"name":"erc20DiscountCurrentlyApplies","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"},{"internalType":"bytes32","name":"_discountId","type":"bytes32"}],"name":"getDiscountRedemptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"getPlanEOL","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"}],"name":"getPlanStatus","outputs":[{"internalType":"enum ICaskSubscriptionPlans.PlanStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"}],"name":"getProviderProfile","outputs":[{"components":[{"internalType":"address","name":"paymentAddress","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"string","name":"cid","type":"string"}],"internalType":"struct ICaskSubscriptionPlans.Provider","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_planId","type":"uint32"},{"internalType":"uint32","name":"_retireAt","type":"uint32"}],"name":"retirePlan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriptionManager","type":"address"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_paymentAddress","type":"address"},{"internalType":"string","name":"_cid","type":"string"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"setProviderProfile","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscriptions","type":"address"}],"name":"setSubscriptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subscriptionManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"subscriptions","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"},{"internalType":"bytes32[]","name":"_discountProof","type":"bytes32[]"}],"name":"verifyAndConsumeDiscount","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_consumer","type":"address"},{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint32","name":"_planId","type":"uint32"},{"internalType":"bytes32[]","name":"_discountProof","type":"bytes32[]"}],"name":"verifyDiscount","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_network","type":"address"},{"internalType":"bytes32","name":"_networkData","type":"bytes32"},{"internalType":"bytes","name":"_networkSignature","type":"bytes"}],"name":"verifyNetworkData","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_planData","type":"bytes32"},{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"}],"name":"verifyPlan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_provider","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"},{"internalType":"bytes32","name":"_planMerkleRoot","type":"bytes32"},{"internalType":"bytes32","name":"_discountMerkleRoot","type":"bytes32"},{"internalType":"bytes","name":"_providerSignature","type":"bytes"}],"name":"verifyProviderSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"versionRecipient","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]

60806040523480156200001157600080fd5b50600054600160a81b900460ff166200003857600054600160a01b900460ff161562000042565b62000042620000f1565b620000aa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054600160a81b900460ff16158015620000d5576000805461ffff60a01b191661010160a01b1790555b8015620000ea576000805460ff60a81b191690555b5062000115565b600062000109306200010f60201b620014481760201c565b15905090565b3b151590565b61284880620001256000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80637f116d8811610104578063b8e381e5116100a2578063cd1402e711610071578063cd1402e714610430578063d0ebdbe714610443578063da74222814610456578063f2fde38b1461046957600080fd5b8063b8e381e5146103e4578063be8b0f3e146103f7578063bf158fd21461040a578063c5b2cfce1461041d57600080fd5b80638da5cb5b116100de5780638da5cb5b1461035f5780639c4f7d5914610370578063b0d8985c14610383578063b6ab359f1461039657600080fd5b80637f116d881461033c5780638129fc1c1461034f5780638456cb591461035757600080fd5b8063572b6c051161017157806371ce3e661161014b57806371ce3e66146102de578063762f3e3d146102f157806379c19bc4146103045780637da0a8771461031757600080fd5b8063572b6c05146102995780635c975abb146102cb578063715018a6146102d657600080fd5b8063256c6ba9116101ad578063256c6ba9146102375780633c17dac81461024a5780633f4ba83a1461026a578063486ff0cd1461027257600080fd5b8063025b6875146101d45780631bc569b5146102015780632218d7d314610216575b600080fd5b6101e76101e2366004612044565b61047c565b60405163ffffffff90911681526020015b60405180910390f35b61021461020f366004612077565b6104af565b005b6102296102243660046120d7565b6105df565b6040519081526020016101f8565b610214610245366004612077565b6106cd565b61025d61025836600461214d565b6107f9565b6040516101f891906121b5565b6102146108e4565b60408051808201825260058152640322e322e360dc1b602082015290516101f891906121ec565b6102bb6102a736600461214d565b6000546001600160a01b0391821691161490565b60405190151581526020016101f8565b60655460ff166102bb565b610214610937565b6102bb6102ec3660046121ff565b61098a565b6102296102ff366004612252565b6109f8565b6102296103123660046120d7565b610a32565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016101f8565b6102bb61034a366004612331565b610af0565b610214610c97565b610214610d83565b6033546001600160a01b0316610324565b61021461037e36600461214d565b610dd4565b61021461039136600461239c565b610e3f565b6103d76103a4366004612044565b6001600160a01b038216600090815260996020908152604080832063ffffffff8516845290915290205460ff1692915050565b6040516101f8919061243b565b609c54610324906001600160a01b031681565b6102bb610405366004612463565b610f3a565b609754610324906001600160a01b031681565b61021461042b3660046124ba565b611029565b6102bb61043e3660046124d6565b611124565b61021461045136600461214d565b6112bf565b61021461046436600461214d565b61132a565b61021461047736600461214d565b611391565b6001600160a01b0382166000908152609a6020908152604080832063ffffffff8086168552925290912054165b92915050565b6000609960006104bd61144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff8616825290925290205460ff1660028111156104fe576104fe612425565b1461053f5760405162461bcd60e51b815260206004820152600c60248201526b085393d517d153905093115160a21b60448201526064015b60405180910390fd5b60016099600061054d61144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff861682529092529020805460ff1916600183600281111561059357610593612425565b02179055508063ffffffff166105a761144e565b6001600160a01b03167f50ec551c598cd517a78f91d12398f4f1d95e0171a4393505d01401f8b6c940a760405160405180910390a350565b609c546000906001600160a01b03166105f661144e565b6001600160a01b0316146106345760405162461bcd60e51b815260206004820152600560248201526404282aaa8960db1b6044820152606401610536565b60006106438787878787610a32565b905080156106c157600061066f8585600181811061066357610663612500565b9050602002013561145d565b6001600160a01b0388166000908152609b60209081526040808320608085015163ffffffff1684528252808320868452909152812080549293506001929091906106ba90849061252c565b9091555050505b90505b95945050505050565b6001609960006106db61144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff8616825290925290205460ff16600281111561071c5761071c612425565b146107595760405162461bcd60e51b815260206004820152600d60248201526c085393d517d11254d050931151609a1b6044820152606401610536565b60006099600061076761144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff861682529092529020805460ff191660018360028111156107ad576107ad612425565b02179055508063ffffffff166107c161144e565b6001600160a01b03167fb6af1d2951898e17e763c18b77daf0ada2f2753802d37868e67797e87991a29860405160405180910390a350565b6040805160608082018352600080835260208084018290528385018390526001600160a01b0386811683526098825291859020855193840186528054909216835260018201549083015260028101805493949293919284019161085b90612544565b80601f016020809104026020016040519081016040528092919081815260200182805461088790612544565b80156108d45780601f106108a9576101008083540402835291602001916108d4565b820191906000526020600020905b8154815290600101906020018083116108b757829003601f168201915b5050505050815250509050919050565b6108ec61144e565b6001600160a01b03166109076033546001600160a01b031690565b6001600160a01b03161461092d5760405162461bcd60e51b81526004016105369061257f565b610935611545565b565b61093f61144e565b6001600160a01b031661095a6033546001600160a01b031690565b6001600160a01b0316146109805760405162461bcd60e51b81526004016105369061257f565b61093560006115de565b60006109ed8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060408051602081018b90528993500190505b60405160208183030381529060405280519060200120611630565b90505b949350505050565b6001600160a01b0383166000908152609b6020908152604080832063ffffffff8616845282528083208484529091529020545b9392505050565b60006003821080610a5e575082826000818110610a5157610a51612500565b905060200201356000801b145b15610a6b575060006106c4565b6000610a8f84846001818110610a8357610a83612500565b90506020020135611646565b90506001816002811115610aa557610aa5612425565b1415610abf57610ab78686868661165d565b9150506106c4565b6002816002811115610ad357610ad3612425565b1415610ae657610ab7878787878761172b565b50600090506106c4565b6040805160208101869052908101849052606081018390526000908190610b75906080015b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b9050825160001415610c4757604051630b135d3f60e11b81526000906001600160a01b03891690631626ba7e90610bb290859088906004016125b4565b60206040518083038186803b158015610bca57600080fd5b505afa158015610bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0291906125cd565b90506001600160e01b03198116630b135d3f60e11b148015610c3e57506001600160a01b03881660009081526098602052604090206001015487145b925050506106c4565b6000610c5382856117d7565b9050876001600160a01b0316816001600160a01b0316148015610c3e57505050506001600160a01b03851660009081526098602052604090206001015484146106c4565b600054600160a81b900460ff16610cbb57600054600160a01b900460ff1615610cbf565b303b155b610d225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610536565b600054600160a81b900460ff16158015610d4c576000805461ffff60a01b191661010160a01b1790555b610d546117fb565b610d5c611834565b609c80546001600160a01b03191690558015610d80576000805460ff60a81b191690555b50565b610d8b61144e565b6001600160a01b0316610da66033546001600160a01b031690565b6001600160a01b031614610dcc5760405162461bcd60e51b81526004016105369061257f565b61093561186d565b610ddc61144e565b6001600160a01b0316610df76033546001600160a01b031690565b6001600160a01b031614610e1d5760405162461bcd60e51b81526004016105369061257f565b609c80546001600160a01b0319166001600160a01b0392909216919091179055565b600060986000610e4d61144e565b6001600160a01b031681526020810191909152604001600020600181015490915015610eaf5780600101548211610eaf5760405162461bcd60e51b8152602060048201526006602482015265214e4f4e434560d01b6044820152606401610536565b80546001600160a01b0319166001600160a01b038616178155610ed6600282018585611f7b565b50600181018290556001600160a01b038516610ef061144e565b6001600160a01b03167e0b4932fa91cc5ebcac0f9fb3ab2ae36eb6ba359cdd98d49954b5a700a21109848787604051610f2b939291906125f7565b60405180910390a35050505050565b600080610f5384604051602001610b1591815260200190565b9050825160001415610ffd57604051630b135d3f60e11b81526000906001600160a01b03871690631626ba7e90610f9090859088906004016125b4565b60206040518083038186803b158015610fa857600080fd5b505afa158015610fbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe091906125cd565b6001600160e01b031916630b135d3f60e11b149250610a2b915050565b600061100982856117d7565b9050856001600160a01b0316816001600160a01b03161492505050610a2b565b60026099600061103761144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff871682529092529020805460ff1916600183600281111561107d5761107d612425565b021790555080609a600061108f61144e565b6001600160a01b031681526020808201929092526040908101600090812063ffffffff87811680845291909452919020805463ffffffff1916939092169290921790556110da61144e565b60405163ffffffff841681526001600160a01b0391909116907fb14722ab80cf12b24122b69280630813ed38d597d93a29801fa9087cb8968a5d9060200160405180910390a35050565b6000606082901c60ff605884901c8116908114156111e857816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561117557600080fd5b505afa9250505080156111a5575060408051601f3d908101601f191682019092526111a29181019061262d565b60015b6111e5573d8080156111d3576040519150601f19603f3d011682016040523d82523d6000602084013e6111d8565b606091505b50600093505050506104a9565b90505b6040516370a0823160e01b81526001600160a01b0386811660048301528316906370a082319060240160206040518083038186803b15801561122957600080fd5b505afa925050508015611259575060408051601f3d908101601f1916820190925261125691810190612650565b60015b611287573d8080156111d3576040519150601f19603f3d011682016040523d82523d6000602084013e6111d8565b60ff8216156112a85761129b82600a61274d565b6112a5908261275c565b90505b67ffffffffffffffff8516111592506104a9915050565b6112c761144e565b6001600160a01b03166112e26033546001600160a01b031690565b6001600160a01b0316146113085760405162461bcd60e51b81526004016105369061257f565b609780546001600160a01b0319166001600160a01b0392909216919091179055565b61133261144e565b6001600160a01b031661134d6033546001600160a01b031690565b6001600160a01b0316146113735760405162461bcd60e51b81526004016105369061257f565b600080546001600160a01b0319166001600160a01b03831617905550565b61139961144e565b6001600160a01b03166113b46033546001600160a01b031690565b6001600160a01b0316146113da5760405162461bcd60e51b81526004016105369061257f565b6001600160a01b03811661143f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610536565b610d80816115de565b3b151590565b60006114586118e9565b905090565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810191909152604080516101008101825260a084811c825263ffffffff608086811c8216602080860191909152606088811c8416868801529588901c8316958501959095529386901c169282019290925261ffff601085901c169181019190915260f083901b9060c0810160ff8516600281111561151857611518612425565b600281111561152957611529612425565b8152600160f81b92831690921460209092019190915292915050565b60655460ff1661158e5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610536565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6115c161144e565b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008261163d858461191d565b14949350505050565b600060ff821660028111156104a9576104a9612425565b6000600382108061168957508282600081811061167c5761167c612500565b905060200201356000801b145b15611696575060006109f0565b6000838360008181106116ab576116ab612500565b905060200201356040516020016116c491815260200190565b6040516020818303038152906040528051906020012090506116e78185856119c1565b801561171357506117138187878787600181811061170757611707612500565b90506020020135611aa6565b1561171f5790506109f0565b50600095945050505050565b6000600382108061175757508282600081811061174a5761174a612500565b905060200201356000801b145b15611764575060006106c4565b60008383600081811061177957611779612500565b90506020020135905061178d8185856119c1565b801561179e575061179e8782611124565b80156117be57506117be8187878787600181811061170757611707612500565b156117ca5790506106c4565b5060009695505050505050565b60008060006117e68585611b9d565b915091506117f381611c0d565b509392505050565b600054600160a81b900460ff166118245760405162461bcd60e51b81526004016105369061277e565b61182c611dc8565b610935611df1565b600054600160a81b900460ff1661185d5760405162461bcd60e51b81526004016105369061277e565b611865611dc8565b610935611e2a565b60655460ff16156118b35760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610536565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586115c161144e565b60006014361080159061190657506000546001600160a01b031633145b15611918575060131936013560601c90565b503390565b600081815b84518110156117f357600085828151811061193f5761193f612500565b602002602001015190508083116119815760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506119ae565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806119b9816127c9565b915050611922565b600060038210806119ed5750828260008181106119e0576119e0612500565b905060200201356000801b145b156119fa57506000610a2b565b60408051600081526020810190915260048310611a5357611a1e83600381876127e4565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509293505050505b6106c48185856002818110611a6a57611a6a612500565b905060200201358787876001818110611a8557611a85612500565b905060200201356040516020016109d2929190918252602082015260400190565b600080611ab28361145d565b9050806080015163ffffffff1660001480611adc57508363ffffffff16816080015163ffffffff16145b8015611b385750606081015163ffffffff161580611b38575060608101516001600160a01b0386166000908152609b60209081526040808320608086015163ffffffff90811685529083528184208b8552909252909120549116115b8015611b665750602081015163ffffffff161580611b6657504263ffffffff16816020015163ffffffff1611155b8015611b935750604081015163ffffffff161580611b9357504263ffffffff16816040015163ffffffff16115b9695505050505050565b600080825160411415611bd45760208301516040840151606085015160001a611bc887828585611e5f565b94509450505050611c06565b825160401415611bfe5760208301516040840151611bf3868383611f4c565b935093505050611c06565b506000905060025b9250929050565b6000816004811115611c2157611c21612425565b1415611c2a5750565b6001816004811115611c3e57611c3e612425565b1415611c8c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610536565b6002816004811115611ca057611ca0612425565b1415611cee5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610536565b6003816004811115611d0257611d02612425565b1415611d5b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610536565b6004816004811115611d6f57611d6f612425565b1415610d805760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610536565b600054600160a81b900460ff166109355760405162461bcd60e51b81526004016105369061277e565b600054600160a81b900460ff16611e1a5760405162461bcd60e51b81526004016105369061277e565b610935611e2561144e565b6115de565b600054600160a81b900460ff16611e535760405162461bcd60e51b81526004016105369061277e565b6065805460ff19169055565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611e965750600090506003611f43565b8460ff16601b14158015611eae57508460ff16601c14155b15611ebf5750600090506004611f43565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611f13573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f3c57600060019250925050611f43565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01611f6d87828885611e5f565b935093505050935093915050565b828054611f8790612544565b90600052602060002090601f016020900481019282611fa95760008555611fef565b82601f10611fc25782800160ff19823516178555611fef565b82800160010185558215611fef579182015b82811115611fef578235825591602001919060010190611fd4565b50611ffb929150611fff565b5090565b5b80821115611ffb5760008155600101612000565b80356001600160a01b038116811461202b57600080fd5b919050565b803563ffffffff8116811461202b57600080fd5b6000806040838503121561205757600080fd5b61206083612014565b915061206e60208401612030565b90509250929050565b60006020828403121561208957600080fd5b610a2b82612030565b60008083601f8401126120a457600080fd5b50813567ffffffffffffffff8111156120bc57600080fd5b6020830191508360208260051b8501011115611c0657600080fd5b6000806000806000608086880312156120ef57600080fd5b6120f886612014565b945061210660208701612014565b935061211460408701612030565b9250606086013567ffffffffffffffff81111561213057600080fd5b61213c88828901612092565b969995985093965092949392505050565b60006020828403121561215f57600080fd5b610a2b82612014565b6000815180845260005b8181101561218e57602081850181015186830182015201612172565b818111156121a0576000602083870101525b50601f01601f19169290920160200192915050565b6020815260018060a01b03825116602082015260208201516040820152600060408301516060808401526109f06080840182612168565b602081526000610a2b6020830184612168565b6000806000806060858703121561221557600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561223a57600080fd5b61224687828801612092565b95989497509550505050565b60008060006060848603121561226757600080fd5b61227084612014565b925061227e60208501612030565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126122b557600080fd5b813567ffffffffffffffff808211156122d0576122d061228e565b604051601f8301601f19908116603f011681019082821181831017156122f8576122f861228e565b8160405283815286602085880101111561231157600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600060a0868803121561234957600080fd5b61235286612014565b9450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561238357600080fd5b61238f888289016122a4565b9150509295509295909350565b600080600080606085870312156123b257600080fd5b6123bb85612014565b9350602085013567ffffffffffffffff808211156123d857600080fd5b818701915087601f8301126123ec57600080fd5b8135818111156123fb57600080fd5b88602082850101111561240d57600080fd5b95986020929092019750949560400135945092505050565b634e487b7160e01b600052602160045260246000fd5b602081016003831061245d57634e487b7160e01b600052602160045260246000fd5b91905290565b60008060006060848603121561247857600080fd5b61248184612014565b925060208401359150604084013567ffffffffffffffff8111156124a457600080fd5b6124b0868287016122a4565b9150509250925092565b600080604083850312156124cd57600080fd5b61206083612030565b600080604083850312156124e957600080fd5b6124f283612014565b946020939093013593505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561253f5761253f612516565b500190565b600181811c9082168061255857607f821691505b6020821081141561257957634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b8281526040602082015260006109f06040830184612168565b6000602082840312156125df57600080fd5b81516001600160e01b031981168114610a2b57600080fd5b83815260406020820152816040820152818360608301376000818301606090810191909152601f909201601f1916010192915050565b60006020828403121561263f57600080fd5b815160ff81168114610a2b57600080fd5b60006020828403121561266257600080fd5b5051919050565b600181815b808511156126a457816000190482111561268a5761268a612516565b8085161561269757918102915b93841c939080029061266e565b509250929050565b6000826126bb575060016104a9565b816126c8575060006104a9565b81600181146126de57600281146126e857612704565b60019150506104a9565b60ff8411156126f9576126f9612516565b50506001821b6104a9565b5060208310610133831016604e8410600b8410161715612727575081810a6104a9565b6127318383612669565b806000190482111561274557612745612516565b029392505050565b6000610a2b60ff8416836126ac565b60008261277957634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006000198214156127dd576127dd612516565b5060010190565b600080858511156127f457600080fd5b8386111561280157600080fd5b5050600583901b019391909203915056fea2646970667358221220351e3383ff23b87a910cc3c244105d49cfa0e87612e41faeb9cde4421b02801464736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.