ETH Price: $2,521.82 (+2.76%)
Gas: 0.67 Gwei

Contract

0xdD813397b79f8df581eEb0c4B8aB72304c528396
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60a06040162334422022-12-21 13:42:23621 days ago1671630143IN
 Create: StarkPerpetual
0 ETH0.0187199215.46180291

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StarkPerpetual

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion, Apache-2.0 license
File 1 of 15 : StarkPerpetual.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "MainDispatcher.sol";
import "PerpetualStorage.sol";

contract StarkPerpetual is MainDispatcher, PerpetualStorage {
    string public constant VERSION = "3.1.0";

    // Salt for a 8 bit unique spread of all relevant selectors. Pre-caclulated.
    // ---------- The following code was auto-generated. PLEASE DO NOT EDIT. ----------
    uint256 constant MAGIC_SALT = 349548;
    uint256 constant IDX_MAP_0 = 0x2124100000000202022040002000000020022010011100002003000001000000;
    uint256 constant IDX_MAP_1 = 0x10003203010020002002200030330000100020300002001003030000100202;
    uint256 constant IDX_MAP_2 = 0x3000002000310000040022000010000000100013430002033100300200000302;
    uint256 constant IDX_MAP_3 = 0x1103103010020000102000000400320031030100023000004000300000000000;

    // ---------- End of auto-generated code. ----------

    function getNumSubcontracts() internal pure override returns (uint256) {
        return 4;
    }

    function magicSalt() internal pure override returns (uint256) {
        return MAGIC_SALT;
    }

    function handlerMapSection(uint256 section) internal pure override returns (uint256) {
        if (section == 0) {
            return IDX_MAP_0;
        } else if (section == 1) {
            return IDX_MAP_1;
        } else if (section == 2) {
            return IDX_MAP_2;
        } else if (section == 3) {
            return IDX_MAP_3;
        }
        revert("BAD_IDX_MAP_SECTION");
    }

    function expectedIdByIndex(uint256 index) internal pure override returns (string memory id) {
        if (index == 1) {
            id = "StarkWare_AllVerifiers_2022_2";
        } else if (index == 2) {
            id = "StarkWare_PerpetualTokensAndRamping_2022_2";
        } else if (index == 3) {
            id = "StarkWare_PerpetualState_2022_3";
        } else if (index == 4) {
            id = "StarkWare_PerpetualForcedActions_2022_2";
        } else {
            revert("UNEXPECTED_INDEX");
        }
    }

    function initializationSentinel() internal view override {
        string memory REVERT_MSG = "INITIALIZATION_BLOCKED";
        // This initializer sets state etc. It must not be applied twice.
        // I.e. it can run only when the state is still empty.
        require(int256(sharedStateHash) == 0, REVERT_MSG);
        require(int256(globalConfigurationHash) == 0, REVERT_MSG);
        require(systemAssetType == 0, REVERT_MSG);
    }
}

File 2 of 15 : Addresses.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

/*
  Common Utility Libraries.
  I. Addresses (extending address).
*/
library Addresses {
    /*
      Note: isContract function has some known limitation.
      See https://github.com/OpenZeppelin/
      openzeppelin-contracts/blob/master/contracts/utils/Address.sol.
    */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    function performEthTransfer(address recipient, uint256 amount) internal {
        if (amount == 0) return;
        (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls.
        require(success, "ETH_TRANSFER_FAILED");
    }

    /*
      Safe wrapper around ERC20/ERC721 calls.
      This is required because many deployed ERC20 contracts don't return a value.
      See https://github.com/ethereum/solidity/issues/4116.
    */
    function safeTokenContractCall(address tokenAddress, bytes memory callData) internal {
        require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS");
        // NOLINTNEXTLINE: low-level-calls.
        (bool success, bytes memory returndata) = tokenAddress.call(callData);
        require(success, string(returndata));

        if (returndata.length > 0) {
            require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED");
        }
    }
}

File 3 of 15 : BlockDirectCall.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

/*
  This contract provides means to block direct call of an external function.
  A derived contract (e.g. MainDispatcherBase) should decorate sensitive functions with the
  notCalledDirectly modifier, thereby preventing it from being called directly, and allowing only
  calling using delegate_call.
*/
abstract contract BlockDirectCall {
    address immutable this_;

    constructor() internal {
        this_ = address(this);
    }

    modifier notCalledDirectly() {
        require(this_ != address(this), "DIRECT_CALL_DISALLOWED");
        _;
    }
}

File 4 of 15 : Governance.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "MGovernance.sol";

/*
  Implements Generic Governance, applicable for both proxy and main contract, and possibly others.
  Notes:
   The use of the same function names by both the Proxy and a delegated implementation
   is not possible since calling the implementation functions is done via the default function
   of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance)
   exposes mainIsGovernor, which calls the internal _isGovernor method.
*/
struct GovernanceInfoStruct {
    mapping(address => bool) effectiveGovernors;
    address candidateGovernor;
    bool initialized;
}

abstract contract Governance is MGovernance {
    event LogNominatedGovernor(address nominatedGovernor);
    event LogNewGovernorAccepted(address acceptedGovernor);
    event LogRemovedGovernor(address removedGovernor);
    event LogNominationCancelled();

    function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage);

    /*
      Current code intentionally prevents governance re-initialization.
      This may be a problem in an upgrade situation, in a case that the upgrade-to implementation
      performs an initialization (for real) and within that calls initGovernance().

      Possible workarounds:
      1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG.
         This will remove existing main governance information.
      2. Modify the require part in this function, so that it will exit quietly
         when trying to re-initialize (uncomment the lines below).
    */
    function initGovernance() internal {
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        require(!gub.initialized, "ALREADY_INITIALIZED");
        gub.initialized = true; // to ensure acceptNewGovernor() won't fail.
        // Add the initial governer.
        acceptNewGovernor(msg.sender);
    }

    function _isGovernor(address user) internal view override returns (bool) {
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        return gub.effectiveGovernors[user];
    }

    /*
      Cancels the nomination of a governor candidate.
    */
    function _cancelNomination() internal onlyGovernance {
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        if (gub.candidateGovernor != address(0x0)) {
            gub.candidateGovernor = address(0x0);
            emit LogNominationCancelled();
        }
    }

    function _nominateNewGovernor(address newGovernor) internal onlyGovernance {
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        require(newGovernor != address(0x0), "BAD_ADDRESS");
        require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
        require(gub.candidateGovernor == address(0x0), "OTHER_CANDIDATE_PENDING");
        gub.candidateGovernor = newGovernor;
        emit LogNominatedGovernor(newGovernor);
    }

    /*
      The acceptNewGovernor is called in two cases:
      1. by _acceptGovernance when a new governor accepts its role.
      2. by initGovernance to add the initial governor.
      The difference is that the init path skips the nominate step
      that would fail because of the onlyGovernance modifier.
    */
    function acceptNewGovernor(address newGovernor) private {
        require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR");
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        gub.effectiveGovernors[newGovernor] = true;

        // Emit governance information.
        emit LogNewGovernorAccepted(newGovernor);
    }

    function _acceptGovernance() internal {
        // The new governor was proposed as a candidate by the current governor.
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        require(msg.sender == gub.candidateGovernor, "ONLY_CANDIDATE_GOVERNOR");

        // Update state.
        acceptNewGovernor(msg.sender);
        gub.candidateGovernor = address(0x0);
    }

    /*
      Remove a governor from office.
    */
    function _removeGovernor(address governorForRemoval) internal onlyGovernance {
        require(msg.sender != governorForRemoval, "GOVERNOR_SELF_REMOVE");
        GovernanceInfoStruct storage gub = getGovernanceInfo();
        require(_isGovernor(governorForRemoval), "NOT_GOVERNOR");
        gub.effectiveGovernors[governorForRemoval] = false;
        emit LogRemovedGovernor(governorForRemoval);
    }
}

File 5 of 15 : GovernanceStorage.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;
import {GovernanceInfoStruct} from "Governance.sol";

/*
  Holds the governance slots for ALL entities, including proxy and the main contract.
*/
contract GovernanceStorage {
    // A map from a Governor tag to its own GovernanceInfoStruct.
    mapping(string => GovernanceInfoStruct) internal governanceInfo; //NOLINT uninitialized-state.
}

File 6 of 15 : IDispatcherBase.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

/*
  Interface for a generic dispatcher to use, which the concrete dispatcher must implement.
  It contains the functions that are specific to the concrete dispatcher instance.
  The interface is implemented as contract, because interface implies all methods external.
*/
abstract contract IDispatcherBase {
    function getSubContract(bytes4 selector) public view virtual returns (address);

    function setSubContractAddress(uint256 index, address subContract) internal virtual;

    function getNumSubcontracts() internal pure virtual returns (uint256);

    function validateSubContractIndex(uint256 index, address subContract) internal pure virtual;

    /*
      Ensures initializer can be called. Reverts otherwise.
    */
    function initializationSentinel() internal view virtual;
}

File 7 of 15 : Identity.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

interface Identity {
    /*
      Allows a caller to ensure that the provided address is of the expected type and version.
    */
    function identify() external pure returns (string memory);
}

File 8 of 15 : MGovernance.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

abstract contract MGovernance {
    function _isGovernor(address user) internal view virtual returns (bool);

    /*
      Allows calling the function only by a Governor.
    */
    modifier onlyGovernance() {
        require(_isGovernor(msg.sender), "ONLY_GOVERNANCE");
        _;
    }
}

File 9 of 15 : MainDispatcher.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "MainStorage.sol";
import "MainDispatcherBase.sol";

abstract contract MainDispatcher is MainStorage, MainDispatcherBase {
    uint256 constant SUBCONTRACT_BITS = 4;

    function magicSalt() internal pure virtual returns (uint256);

    function handlerMapSection(uint256 section) internal pure virtual returns (uint256);

    function expectedIdByIndex(uint256 index) internal pure virtual returns (string memory id);

    function validateSubContractIndex(uint256 index, address subContract) internal pure override {
        string memory id = SubContractor(subContract).identify();
        bytes32 hashed_expected_id = keccak256(abi.encodePacked(expectedIdByIndex(index)));
        require(
            hashed_expected_id == keccak256(abi.encodePacked(id)),
            "MISPLACED_INDEX_OR_BAD_CONTRACT_ID"
        );

        // Gets the list of critical selectors from the sub-contract and checks that the selector
        // is mapped to that sub-contract.
        bytes4[] memory selectorsToValidate = SubContractor(subContract).validatedSelectors();

        for (uint256 i = 0; i < selectorsToValidate.length; i++) {
            require(
                getSubContractIndex(selectorsToValidate[i]) == index,
                "INCONSISTENT_DISPATCHER_MAP"
            );
        }
    }

    function handlingContractId(bytes4 selector) external pure virtual returns (string memory id) {
        uint256 index = getSubContractIndex(selector);
        return expectedIdByIndex(index);
    }

    /*
      Returns the index in subContracts where the address of the sub-contract implementing
      the function with the queried selector is held.

      Note: The nature of the sub-contracts handler map is such that all the required selectors
      are mapped. However, other selectors, such that are not implemented in any subcontract,
      may also return a sub-contract address.
      This behavior is by-design, and not a problem.
    */
    function getSubContractIndex(bytes4 selector) internal pure returns (uint256) {
        uint256 location = 0xFF & uint256(keccak256(abi.encodePacked(selector, magicSalt())));
        uint256 offset = (SUBCONTRACT_BITS * location) % 256;

        // We have 64 locations in each register, hence the >> 6 (i.e. location // 64).
        return (handlerMapSection(location >> 6) >> offset) & 0xF;
    }

    /*
      Returns the address of the sub-contract that would be delegated to handle a call
      with the queried selector. (see note above).
    */
    function getSubContract(bytes4 selector) public view override returns (address) {
        return subContracts[getSubContractIndex(selector)];
    }

    function setSubContractAddress(uint256 index, address subContractAddress) internal override {
        subContracts[index] = subContractAddress;
    }
}

File 10 of 15 : MainDispatcherBase.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "SubContractor.sol";
import "IDispatcherBase.sol";
import "BlockDirectCall.sol";
import "Addresses.sol";

abstract contract MainDispatcherBase is IDispatcherBase, BlockDirectCall {
    using Addresses for address;

    /*
      This entry point serves only transactions with empty calldata. (i.e. pure value transfer tx).
      We don't expect to receive such, thus block them.
    */
    receive() external payable {
        revert("CONTRACT_NOT_EXPECTED_TO_RECEIVE");
    }

    fallback() external payable {
        address subContractAddress = getSubContract(msg.sig);
        require(subContractAddress != address(0x0), "NO_CONTRACT_FOR_FUNCTION");

        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 for now, as we don"t know the out size yet.
            let result := delegatecall(gas(), subContractAddress, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /*
      1. Extract subcontracts.
      2. Verify correct sub-contract initializer size.
      3. Extract sub-contract initializer data.
      4. Call sub-contract initializer.

      The init data bytes passed to initialize are structed as following:
      I. N slots (uin256 size) addresses of the deployed sub-contracts.
      II. An address of an external initialization contract (optional, or ZERO_ADDRESS).
      III. (Up to) N bytes sections of the sub-contracts initializers.

      If already initialized (i.e. upgrade) we expect the init data to be consistent with this.
      and if a different size of init data is expected when upgrading, the initializerSize should
      reflect this.

      If an external initializer contract is not used, ZERO_ADDRESS is passed in its slot.
      If the external initializer contract is used, all the remaining init data is passed to it,
      and internal initialization will not occur.

      External Initialization Contract
      --------------------------------
      External Initialization Contract (EIC) is a hook for custom initialization.
      Typically in an upgrade flow, the expected initialization contains only the addresses of
      the sub-contracts. Normal initialization of the sub-contracts is such that is not needed
      in an upgrade, and actually may be very dangerous, as changing of state on a working system
      may corrupt it.

      In the event that some state initialization is required, the EIC is a hook that allows this.
      It may be deployed and called specifically for this purpose.

      The address of the EIC must be provided (if at all) when a new implementation is added to
      a Proxy contract (as part of the initialization vector).
      Hence, it is considered part of the code open to reviewers prior to a time-locked upgrade.

      When a custom initialization is performed using an EIC,
      the main dispatcher initialize extracts and stores the sub-contracts addresses, and then
      yields to the EIC, skipping the rest of its initialization code.


      Flow of MainDispatcher initialize
      ---------------------------------
      1. Extraction and assignment of subcontracts addresses
         Main dispatcher expects a valid and consistent set of addresses in the passed data.
         It validates that, extracts the addresses from the data, and validates that the addresses
         are of the expected type and order. Then those addresses are stored.

      2. Extraction of EIC address
         The address of the EIC is extracted from the data.
         External Initializer Contract is optional. ZERO_ADDRESS indicates it is not used.

      3a. EIC is used
          Dispatcher calls the EIC initialize function with the remaining data.
          Note - In this option 3b is not performed.

      3b. EIC is not used
          If there is additional initialization data then:
          I. Sentitenl function is called to permit subcontracts initialization.
          II. Dispatcher loops through the subcontracts and for each one it extracts the
              initializing data and passes it to the subcontract's initialize function.

    */
    function initialize(bytes calldata data) external virtual notCalledDirectly {
        // Number of sub-contracts.
        uint256 nSubContracts = getNumSubcontracts();

        // We support currently 4 bits per contract, i.e. 16, reserving 00 leads to 15.
        require(nSubContracts <= 15, "TOO_MANY_SUB_CONTRACTS");

        // Sum of subcontract initializers. Aggregated for verification near the end.
        uint256 totalInitSizes = 0;

        // Offset (within data) of sub-contract initializer vector.
        // Just past the sub-contract+eic addresses.
        uint256 initDataContractsOffset = 32 * (nSubContracts + 1);

        // Init data MUST include addresses for all sub-contracts + EIC.
        require(data.length >= initDataContractsOffset, "SUB_CONTRACTS_NOT_PROVIDED");

        // Size of passed data, excluding sub-contract addresses.
        uint256 additionalDataSize = data.length - initDataContractsOffset;

        // Extract & update contract addresses.
        for (uint256 nContract = 1; nContract <= nSubContracts; nContract++) {
            // Extract sub-contract address.
            address contractAddress = abi.decode(
                data[32 * (nContract - 1):32 * nContract],
                (address)
            );

            validateSubContractIndex(nContract, contractAddress);

            // Contracts are indexed from 1 and 0 is not in use here.
            setSubContractAddress(nContract, contractAddress);
        }

        // Check if we have an external initializer contract.
        address externalInitializerAddr = abi.decode(
            data[initDataContractsOffset - 32:initDataContractsOffset],
            (address)
        );

        // 3(a). Yield to EIC initialization.
        if (externalInitializerAddr != address(0x0)) {
            callExternalInitializer(externalInitializerAddr, data[initDataContractsOffset:]);
            return;
        }

        // 3(b). Subcontracts initialization.
        // I. If no init data passed besides sub-contracts, return.
        if (additionalDataSize == 0) {
            return;
        }

        // Just to be on the safe side.
        assert(externalInitializerAddr == address(0x0));

        // II. Gate further initialization.
        initializationSentinel();

        // III. Loops through the subcontracts, extracts their data and calls their initializer.
        for (uint256 nContract = 1; nContract <= nSubContracts; nContract++) {
            // Extract sub-contract address.
            address contractAddress = abi.decode(
                data[32 * (nContract - 1):32 * nContract],
                (address)
            );

            // The initializerSize is called via delegatecall, so that it can relate to the state,
            // and not only to the new contract code. (e.g. return 0 if state-intialized else 192).
            // NOLINTNEXTLINE: controlled-delegatecall low-level-calls calls-loop.
            (bool success, bytes memory returndata) = contractAddress.delegatecall(
                abi.encodeWithSelector(SubContractor(contractAddress).initializerSize.selector)
            );
            require(success, string(returndata));
            uint256 initSize = abi.decode(returndata, (uint256));
            require(initSize <= additionalDataSize, "INVALID_INITIALIZER_SIZE");
            require(totalInitSizes + initSize <= additionalDataSize, "INVALID_INITIALIZER_SIZE");

            if (initSize == 0) {
                continue;
            }

            // Call sub-contract initializer.
            // NOLINTNEXTLINE: controlled-delegatecall calls-loop.
            (success, returndata) = contractAddress.delegatecall(
                abi.encodeWithSelector(
                    this.initialize.selector,
                    data[initDataContractsOffset:initDataContractsOffset + initSize]
                )
            );
            require(success, string(returndata));
            totalInitSizes += initSize;
            initDataContractsOffset += initSize;
        }
        require(additionalDataSize == totalInitSizes, "MISMATCHING_INIT_DATA_SIZE");
    }

    function callExternalInitializer(address externalInitializerAddr, bytes calldata extInitData)
        private
    {
        require(externalInitializerAddr.isContract(), "NOT_A_CONTRACT");

        // NOLINTNEXTLINE: low-level-calls, controlled-delegatecall.
        (bool success, bytes memory returndata) = externalInitializerAddr.delegatecall(
            abi.encodeWithSelector(this.initialize.selector, extInitData)
        );
        require(success, string(returndata));
        require(returndata.length == 0, string(returndata));
    }
}

File 11 of 15 : MainStorage.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "ProxyStorage.sol";
import "Addresses.sol";
import {ApprovalChainData} from "StarkExTypes.sol";

/*
  Holds ALL the main contract state (storage) variables.
*/
contract MainStorage is ProxyStorage {
    uint256 internal constant LAYOUT_LENGTH = 2**64;

    address escapeVerifierAddress; // NOLINT: constable-states.

    // Global dex-frozen flag.
    bool stateFrozen; // NOLINT: constable-states.

    // Time when unFreeze can be successfully called (UNFREEZE_DELAY after freeze).
    uint256 unFreezeTime; // NOLINT: constable-states.

    // Pending deposits.
    // A map STARK key => asset id => vault id => quantized amount.
    mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) pendingDeposits;

    // Cancellation requests.
    // A map STARK key => asset id => vault id => request timestamp.
    mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) cancellationRequests;

    // Pending withdrawals.
    // A map STARK key => asset id => quantized amount.
    mapping(uint256 => mapping(uint256 => uint256)) pendingWithdrawals;

    // vault_id => escape used boolean.
    mapping(uint256 => bool) escapesUsed;

    // Number of escapes that were performed when frozen.
    uint256 escapesUsedCount; // NOLINT: constable-states.

    // NOTE: fullWithdrawalRequests is deprecated, and replaced by forcedActionRequests.
    // NOLINTNEXTLINE naming-convention.
    mapping(uint256 => mapping(uint256 => uint256)) fullWithdrawalRequests_DEPRECATED;

    // State sequence number.
    uint256 sequenceNumber; // NOLINT: constable-states uninitialized-state.

    // Validium Vaults Tree Root & Height.
    uint256 validiumVaultRoot; // NOLINT: constable-states uninitialized-state.
    uint256 validiumTreeHeight; // NOLINT: constable-states uninitialized-state.

    // Order Tree Root & Height.
    uint256 orderRoot; // NOLINT: constable-states uninitialized-state.
    uint256 orderTreeHeight; // NOLINT: constable-states uninitialized-state.

    // True if and only if the address is allowed to add tokens.
    mapping(address => bool) tokenAdmins;

    // This mapping is no longer in use, remains for backwards compatibility.
    mapping(address => bool) userAdmins_DEPRECATED; // NOLINT: naming-convention.

    // True if and only if the address is an operator (allowed to update state).
    mapping(address => bool) operators; // NOLINT: uninitialized-state.

    // Mapping of contract ID to asset data.
    mapping(uint256 => bytes) assetTypeToAssetInfo; // NOLINT: uninitialized-state.

    // Mapping of registered contract IDs.
    mapping(uint256 => bool) registeredAssetType; // NOLINT: uninitialized-state.

    // Mapping from contract ID to quantum.
    mapping(uint256 => uint256) assetTypeToQuantum; // NOLINT: uninitialized-state.

    // This mapping is no longer in use, remains for backwards compatibility.
    mapping(address => uint256) starkKeys_DEPRECATED; // NOLINT: naming-convention.

    // Mapping from STARK public key to the Ethereum public key of its owner.
    mapping(uint256 => address) ethKeys; // NOLINT: uninitialized-state.

    // Timelocked state transition and availability verification chain.
    ApprovalChainData verifiersChain;
    ApprovalChainData availabilityVerifiersChain;

    // Batch id of last accepted proof.
    uint256 lastBatchId; // NOLINT: constable-states uninitialized-state.

    // Mapping between sub-contract index to sub-contract address.
    mapping(uint256 => address) subContracts; // NOLINT: uninitialized-state.

    mapping(uint256 => bool) permissiveAssetType_DEPRECATED; // NOLINT: naming-convention.
    // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX2.0 ----

    // Onchain-data version configured for the system.
    uint256 onchainDataVersion_DEPRECATED; // NOLINT: naming-convention constable-states.

    // Counter of forced action request in block. The key is the block number.
    mapping(uint256 => uint256) forcedRequestsInBlock;

    // ForcedAction requests: actionHash => requestTime.
    mapping(bytes32 => uint256) forcedActionRequests;

    // Mapping for timelocked actions.
    // A actionKey => activation time.
    mapping(bytes32 => uint256) actionsTimeLock;

    // Append only list of requested forced action hashes.
    bytes32[] actionHashList;
    // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX3.0 ----
    // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX4.0 ----

    // Rollup Vaults Tree Root & Height.
    uint256 rollupVaultRoot; // NOLINT: constable-states uninitialized-state.
    uint256 rollupTreeHeight; // NOLINT: constable-states uninitialized-state.

    uint256 globalConfigCode; // NOLINT: constable-states uninitialized-state.

    // Reserved storage space for Extensibility.
    // Every added MUST be added above the end gap, and the __endGap size must be reduced
    // accordingly.
    // NOLINTNEXTLINE: naming-convention.
    uint256[LAYOUT_LENGTH - 40] private __endGap; // __endGap complements layout to LAYOUT_LENGTH.
}

File 12 of 15 : PerpetualStorage.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "MainStorage.sol";

/*
  Extends MainStorage, holds Perpetual App specific state (storage) variables.

  ALL State variables that are common to all applications, reside in MainStorage,
  whereas ALL the Perpetual app specific ones reside here.
*/
contract PerpetualStorage is MainStorage {
    uint256 systemAssetType; // NOLINT: constable-states uninitialized-state.

    bytes32 public globalConfigurationHash; // NOLINT: constable-states uninitialized-state.

    mapping(uint256 => bytes32) public configurationHash; // NOLINT: uninitialized-state.

    bytes32 sharedStateHash; // NOLINT: constable-states uninitialized-state.

    // Configuration apply time-lock.
    // The delay is held in storage (and not constant)
    // So that it can be modified during upgrade.
    uint256 public configurationDelay; // NOLINT: constable-states.

    // Reserved storage space for Extensibility.
    // Every added MUST be added above the end gap, and the __endGap size must be reduced
    // accordingly.
    // NOLINTNEXTLINE: naming-convention shadowing-abstract.
    uint256[LAYOUT_LENGTH - 5] private __endGap; // __endGap complements layout to LAYOUT_LENGTH.
}

File 13 of 15 : ProxyStorage.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "GovernanceStorage.sol";

/*
  Holds the Proxy-specific state variables.
  This contract is inherited by the GovernanceStorage (and indirectly by MainStorage)
  to prevent collision hazard.
*/
contract ProxyStorage is GovernanceStorage {
    // NOLINTNEXTLINE: naming-convention uninitialized-state.
    mapping(address => bytes32) internal initializationHash_DEPRECATED;

    // The time after which we can switch to the implementation.
    // Hash(implementation, data, finalize) => time.
    mapping(bytes32 => uint256) internal enabledTime;

    // A central storage of the flags whether implementation has been initialized.
    // Note - it can be used flexibly enough to accommodate multiple levels of initialization
    // (i.e. using different key salting schemes for different initialization levels).
    mapping(bytes32 => bool) internal initialized;
}

File 14 of 15 : StarkExTypes.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

// Structure representing a list of verifiers (validity/availability).
// A statement is valid only if all the verifiers in the list agree on it.
// Adding a verifier to the list is immediate - this is used for fast resolution of
// any soundness issues.
// Removing a verifier from the list is time-locked, to ensure that any user of the system
// not content with the announced removal has ample time to leave the system before it is
// removed.
struct ApprovalChainData {
    address[] verifiers;
    // Represents the time after which the verifier with the given address can be removed.
    // Removal of the verifier with address A is allowed only in the case the value
    // of verifierAllowedRemovalTime[A] != 0 and verifierAllowedRemovalTime[A] < (current time).
    mapping(address => uint256) verifierAllowedRemovalTime;
}

File 15 of 15 : SubContractor.sol
/*
  Copyright 2019-2022 StarkWare Industries Ltd.

  Licensed under the Apache License, Version 2.0 (the "License").
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  https://www.starkware.co/open-source-license/

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions
  and limitations under the License.
*/
// SPDX-License-Identifier: Apache-2.0.
pragma solidity ^0.6.12;

import "Identity.sol";

interface SubContractor is Identity {
    function initialize(bytes calldata data) external;

    function initializerSize() external view returns (uint256);

    /*
      Returns an array with selectors for validation.
      These selectors are the critical ones for maintaining self custody and anti censorship.
      During the upgrade process, as part of the sub-contract validation, the MainDispatcher
      validates that the selectos are mapped to the correct sub-contract.
    */
    function validatedSelectors() external pure returns (bytes4[] memory);
}

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

Contract Security Audit

Contract ABI

[{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"configurationDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"configurationHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"getSubContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalConfigurationHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"handlingContractId","outputs":[{"internalType":"string","name":"id","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a060405234801561001057600080fd5b5030606081901b6080526114f56100316000398061036d52506114f56000f3fe6080604052600436106100645760003560e01c80632f9014b414610149578063439fab9114610199578063adac3e1514610216578063c1a851301461023d578063d4e878e814610252578063f2011f66146102fb578063ffa1ad7414610325576100b6565b366100b6576040805162461bcd60e51b815260206004820181905260248201527f434f4e54524143545f4e4f545f45585045435445445f544f5f52454345495645604482015290519081900360640190fd5b60006100cd6000356001600160e01b03191661033a565b90506001600160a01b038116610125576040805162461bcd60e51b81526020600482015260186024820152772727afa1a7a72a2920a1aa2fa327a92fa32aa721aa24a7a760411b604482015290519081900360640190fd5b3660008037600080366000845af43d6000803e808015610144573d6000f35b3d6000fd5b34801561015557600080fd5b5061017d6004803603602081101561016c57600080fd5b50356001600160e01b03191661033a565b604080516001600160a01b039092168252519081900360200190f35b3480156101a557600080fd5b50610214600480360360208110156101bc57600080fd5b810190602081018135600160201b8111156101d657600080fd5b8201836020820111156101e857600080fd5b803590602001918460018302840111600160201b8311171561020957600080fd5b50909250905061036b565b005b34801561022257600080fd5b5061022b6109bc565b60408051918252519081900360200190f35b34801561024957600080fd5b5061022b6109ca565b34801561025e57600080fd5b506102866004803603602081101561027557600080fd5b50356001600160e01b0319166109d8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102c05781810151838201526020016102a8565b50505050905090810190601f1680156102ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030757600080fd5b5061022b6004803603602081101561031e57600080fd5b50356109f7565b34801561033157600080fd5b50610286610a11565b6000601e600061034984610a32565b81526020810191909152604001600020546001600160a01b031690505b919050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163014156103e2576040805162461bcd60e51b81526020600482015260166024820152751112549150d517d0d0531317d11254d0531313d5d15160521b604482015290519081900360640190fd5b60006103ec610aab565b9050600f81111561043d576040805162461bcd60e51b8152602060048201526016602482015275544f4f5f4d414e595f5355425f434f4e54524143545360501b604482015290519081900360640190fd5b6000602060018301028084101561049b576040805162461bcd60e51b815260206004820152601a60248201527f5355425f434f4e5452414354535f4e4f545f50524f5649444544000000000000604482015290519081900360640190fd5b80840360015b8481116104f85760006104c0602080840290600019850102898b611424565b60208110156104ce57600080fd5b50356001600160a01b031690506104e58282610ab0565b6104ef8282610e8c565b506001016104a1565b50600061050b83601f198101888a611424565b602081101561051957600080fd5b50356001600160a01b03169050801561054b576105418161053c8886818c611424565b610eba565b50505050506109b8565b8161055a5750505050506109b8565b6001600160a01b0381161561056b57fe5b6105736110c8565b60015b85811161095d5760006105956020808402906000198501028a8c611424565b60208110156105a357600080fd5b506040805160048152602481018252602081018051633cc660ad60e01b6001600160e01b039091161781529151815193356001600160a01b03169450600093606093869392918291908083835b6020831061060f5780518252601f1990920191602091820191016105f0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461066f576040519150601f19603f3d011682016040523d82523d6000602084013e610674565b606091505b50915091508181906107045760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156106c95781810151838201526020016106b1565b50505050905090810190601f1680156106f65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600081806020019051602081101561071c57600080fd5b5051905086811115610770576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b86818a0111156107c2576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b806107d05750505050610955565b836001600160a01b031663439fab9160e01b8d8d8b90858d01926107f693929190611424565b6040516020602482019081526044820183905290819060640184848082843760008382015260408051601f909201601f1990811690940182810390940182529283526020810180516001600160e01b03166001600160e01b0319909916989098178852915182519297909650869550935090915081905083835b6020831061088f5780518252601f199092019160209182019101610870565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108ef576040519150601f19603f3d011682016040523d82523d6000602084013e6108f4565b606091505b50909350915081836109475760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b509788019796909601955050505b600101610576565b508382146109b2576040805162461bcd60e51b815260206004820152601a60248201527f4d49534d41544348494e475f494e49545f444154415f53495a45000000000000604482015290519081900360640190fd5b50505050505b5050565b680100000000000000015481565b680100000000000000045481565b606060006109e583610a32565b90506109f0816111fd565b9392505050565b680100000000000000026020526000908152604090205481565b604051806040016040528060058152602001640332e312e360dc1b81525081565b60008082610a3e611317565b60405160200180836001600160e01b0319168152600401828152602001925050506040516020818303038152906040528051906020012060001c60ff16905060006101008260040281610a8d57fe5b06905080610a9e600684901c61131e565b600f911c16949350505050565b600490565b6060816001600160a01b031663eeb728666040518163ffffffff1660e01b815260040160006040518083038186803b158015610aeb57600080fd5b505afa158015610aff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610b2857600080fd5b8101908080516040519392919084600160201b821115610b4757600080fd5b908301906020820185811115610b5c57600080fd5b8251600160201b811182820188101715610b7557600080fd5b82525081516020918201929091019080838360005b83811015610ba2578181015183820152602001610b8a565b50505050905090810190601f168015610bcf5780820380516001836020036101000a031916815260200191505b5060405250505090506000610be3846111fd565b6040516020018082805190602001908083835b60208310610c155780518252601f199092019160209182019101610bf6565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050816040516020018082805190602001908083835b60208310610c855780518252601f199092019160209182019101610c66565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001208114610cfd5760405162461bcd60e51b81526004018080602001828103825260228152602001806114776022913960400191505060405180910390fd5b6060836001600160a01b0316630ebdac036040518163ffffffff1660e01b815260040160006040518083038186803b158015610d3857600080fd5b505afa158015610d4c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610d7557600080fd5b8101908080516040519392919084600160201b821115610d9457600080fd5b908301906020820185811115610da957600080fd5b82518660208202830111600160201b82111715610dc557600080fd5b82525081516020918201928201910280838360005b83811015610df2578181015183820152602001610dda565b50505050905001604052505050905060005b8151811015610e845785610e2a838381518110610e1d57fe5b6020026020010151610a32565b14610e7c576040805162461bcd60e51b815260206004820152601b60248201527f494e434f4e53495354454e545f444953504154434845525f4d41500000000000604482015290519081900360640190fd5b600101610e04565b505050505050565b6000918252601e602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610ecc836001600160a01b031661141e565b610f0e576040805162461bcd60e51b815260206004820152600e60248201526d1393d517d057d0d3d395149050d560921b604482015290519081900360640190fd5b60006060846001600160a01b031663439fab9160e01b85856040516024018080602001828103825284848281815260200192508082843760008382015260408051601f909201601f1990811690940182810390940182529283526020810180516001600160e01b03166001600160e01b0319909916989098178852915182519297909650869550935090915081905083835b60208310610fbf5780518252601f199092019160209182019101610fa0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461101f576040519150601f19603f3d011682016040523d82523d6000602084013e611024565b606091505b50915091508181906110775760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b508051819015610e845760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b60408051808201909152601681527512539255125053125690551253d397d09313d0d2d15160521b6020820152680100000000000000035481901561114e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b5068010000000000000001548190156111a85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b50600160401b548190156109b85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b60608160011415611242575060408051808201909152601d81527f537461726b576172655f416c6c5665726966696572735f323032325f320000006020820152610366565b816002141561126b576040518060600160405280602a815260200161144d602a91399050610366565b81600314156112ae575060408051808201909152601f81527f537461726b576172655f50657270657475616c53746174655f323032325f33006020820152610366565b81600414156112d757604051806060016040528060278152602001611499602791399050610366565b6040805162461bcd60e51b815260206004820152601060248201526f0aa9c8ab0a08a86a88a88be929c888ab60831b604482015290519081900360640190fd5b6205556c90565b60008161134c57507f2124100000000202022040002000000020022010011100002003000001000000610366565b816001141561137b57507e10003203010020002002200030330000100020300002001003030000100202610366565b81600214156113ab57507f3000002000310000040022000010000000100013430002033100300200000302610366565b81600314156113db57507f1103103010020000102000000400320031030100023000004000300000000000610366565b6040805162461bcd60e51b81526020600482015260136024820152722120a22fa4a22c2fa6a0a82fa9a2a1aa24a7a760691b604482015290519081900360640190fd5b3b151590565b60008085851115611433578182fd5b8386111561143f578182fd5b505082019391909203915056fe537461726b576172655f50657270657475616c546f6b656e73416e6452616d70696e675f323032325f324d4953504c414345445f494e4445585f4f525f4241445f434f4e54524143545f4944537461726b576172655f50657270657475616c466f72636564416374696f6e735f323032325f32a2646970667358221220b5b3ad47c772145dec9bfe5706d5cc61a680d96f1c8548c5c12091418f1ba96d64736f6c634300060c0033

Deployed Bytecode

0x6080604052600436106100645760003560e01c80632f9014b414610149578063439fab9114610199578063adac3e1514610216578063c1a851301461023d578063d4e878e814610252578063f2011f66146102fb578063ffa1ad7414610325576100b6565b366100b6576040805162461bcd60e51b815260206004820181905260248201527f434f4e54524143545f4e4f545f45585045435445445f544f5f52454345495645604482015290519081900360640190fd5b60006100cd6000356001600160e01b03191661033a565b90506001600160a01b038116610125576040805162461bcd60e51b81526020600482015260186024820152772727afa1a7a72a2920a1aa2fa327a92fa32aa721aa24a7a760411b604482015290519081900360640190fd5b3660008037600080366000845af43d6000803e808015610144573d6000f35b3d6000fd5b34801561015557600080fd5b5061017d6004803603602081101561016c57600080fd5b50356001600160e01b03191661033a565b604080516001600160a01b039092168252519081900360200190f35b3480156101a557600080fd5b50610214600480360360208110156101bc57600080fd5b810190602081018135600160201b8111156101d657600080fd5b8201836020820111156101e857600080fd5b803590602001918460018302840111600160201b8311171561020957600080fd5b50909250905061036b565b005b34801561022257600080fd5b5061022b6109bc565b60408051918252519081900360200190f35b34801561024957600080fd5b5061022b6109ca565b34801561025e57600080fd5b506102866004803603602081101561027557600080fd5b50356001600160e01b0319166109d8565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102c05781810151838201526020016102a8565b50505050905090810190601f1680156102ed5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030757600080fd5b5061022b6004803603602081101561031e57600080fd5b50356109f7565b34801561033157600080fd5b50610286610a11565b6000601e600061034984610a32565b81526020810191909152604001600020546001600160a01b031690505b919050565b7f000000000000000000000000dd813397b79f8df581eeb0c4b8ab72304c5283966001600160a01b03163014156103e2576040805162461bcd60e51b81526020600482015260166024820152751112549150d517d0d0531317d11254d0531313d5d15160521b604482015290519081900360640190fd5b60006103ec610aab565b9050600f81111561043d576040805162461bcd60e51b8152602060048201526016602482015275544f4f5f4d414e595f5355425f434f4e54524143545360501b604482015290519081900360640190fd5b6000602060018301028084101561049b576040805162461bcd60e51b815260206004820152601a60248201527f5355425f434f4e5452414354535f4e4f545f50524f5649444544000000000000604482015290519081900360640190fd5b80840360015b8481116104f85760006104c0602080840290600019850102898b611424565b60208110156104ce57600080fd5b50356001600160a01b031690506104e58282610ab0565b6104ef8282610e8c565b506001016104a1565b50600061050b83601f198101888a611424565b602081101561051957600080fd5b50356001600160a01b03169050801561054b576105418161053c8886818c611424565b610eba565b50505050506109b8565b8161055a5750505050506109b8565b6001600160a01b0381161561056b57fe5b6105736110c8565b60015b85811161095d5760006105956020808402906000198501028a8c611424565b60208110156105a357600080fd5b506040805160048152602481018252602081018051633cc660ad60e01b6001600160e01b039091161781529151815193356001600160a01b03169450600093606093869392918291908083835b6020831061060f5780518252601f1990920191602091820191016105f0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461066f576040519150601f19603f3d011682016040523d82523d6000602084013e610674565b606091505b50915091508181906107045760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156106c95781810151838201526020016106b1565b50505050905090810190601f1680156106f65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600081806020019051602081101561071c57600080fd5b5051905086811115610770576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b86818a0111156107c2576040805162461bcd60e51b8152602060048201526018602482015277494e56414c49445f494e495449414c495a45525f53495a4560401b604482015290519081900360640190fd5b806107d05750505050610955565b836001600160a01b031663439fab9160e01b8d8d8b90858d01926107f693929190611424565b6040516020602482019081526044820183905290819060640184848082843760008382015260408051601f909201601f1990811690940182810390940182529283526020810180516001600160e01b03166001600160e01b0319909916989098178852915182519297909650869550935090915081905083835b6020831061088f5780518252601f199092019160209182019101610870565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146108ef576040519150601f19603f3d011682016040523d82523d6000602084013e6108f4565b606091505b50909350915081836109475760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b509788019796909601955050505b600101610576565b508382146109b2576040805162461bcd60e51b815260206004820152601a60248201527f4d49534d41544348494e475f494e49545f444154415f53495a45000000000000604482015290519081900360640190fd5b50505050505b5050565b680100000000000000015481565b680100000000000000045481565b606060006109e583610a32565b90506109f0816111fd565b9392505050565b680100000000000000026020526000908152604090205481565b604051806040016040528060058152602001640332e312e360dc1b81525081565b60008082610a3e611317565b60405160200180836001600160e01b0319168152600401828152602001925050506040516020818303038152906040528051906020012060001c60ff16905060006101008260040281610a8d57fe5b06905080610a9e600684901c61131e565b600f911c16949350505050565b600490565b6060816001600160a01b031663eeb728666040518163ffffffff1660e01b815260040160006040518083038186803b158015610aeb57600080fd5b505afa158015610aff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610b2857600080fd5b8101908080516040519392919084600160201b821115610b4757600080fd5b908301906020820185811115610b5c57600080fd5b8251600160201b811182820188101715610b7557600080fd5b82525081516020918201929091019080838360005b83811015610ba2578181015183820152602001610b8a565b50505050905090810190601f168015610bcf5780820380516001836020036101000a031916815260200191505b5060405250505090506000610be3846111fd565b6040516020018082805190602001908083835b60208310610c155780518252601f199092019160209182019101610bf6565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050816040516020018082805190602001908083835b60208310610c855780518252601f199092019160209182019101610c66565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001208114610cfd5760405162461bcd60e51b81526004018080602001828103825260228152602001806114776022913960400191505060405180910390fd5b6060836001600160a01b0316630ebdac036040518163ffffffff1660e01b815260040160006040518083038186803b158015610d3857600080fd5b505afa158015610d4c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610d7557600080fd5b8101908080516040519392919084600160201b821115610d9457600080fd5b908301906020820185811115610da957600080fd5b82518660208202830111600160201b82111715610dc557600080fd5b82525081516020918201928201910280838360005b83811015610df2578181015183820152602001610dda565b50505050905001604052505050905060005b8151811015610e845785610e2a838381518110610e1d57fe5b6020026020010151610a32565b14610e7c576040805162461bcd60e51b815260206004820152601b60248201527f494e434f4e53495354454e545f444953504154434845525f4d41500000000000604482015290519081900360640190fd5b600101610e04565b505050505050565b6000918252601e602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610ecc836001600160a01b031661141e565b610f0e576040805162461bcd60e51b815260206004820152600e60248201526d1393d517d057d0d3d395149050d560921b604482015290519081900360640190fd5b60006060846001600160a01b031663439fab9160e01b85856040516024018080602001828103825284848281815260200192508082843760008382015260408051601f909201601f1990811690940182810390940182529283526020810180516001600160e01b03166001600160e01b0319909916989098178852915182519297909650869550935090915081905083835b60208310610fbf5780518252601f199092019160209182019101610fa0565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461101f576040519150601f19603f3d011682016040523d82523d6000602084013e611024565b606091505b50915091508181906110775760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b508051819015610e845760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b60408051808201909152601681527512539255125053125690551253d397d09313d0d2d15160521b6020820152680100000000000000035481901561114e5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b5068010000000000000001548190156111a85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b50600160401b548190156109b85760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156106c95781810151838201526020016106b1565b60608160011415611242575060408051808201909152601d81527f537461726b576172655f416c6c5665726966696572735f323032325f320000006020820152610366565b816002141561126b576040518060600160405280602a815260200161144d602a91399050610366565b81600314156112ae575060408051808201909152601f81527f537461726b576172655f50657270657475616c53746174655f323032325f33006020820152610366565b81600414156112d757604051806060016040528060278152602001611499602791399050610366565b6040805162461bcd60e51b815260206004820152601060248201526f0aa9c8ab0a08a86a88a88be929c888ab60831b604482015290519081900360640190fd5b6205556c90565b60008161134c57507f2124100000000202022040002000000020022010011100002003000001000000610366565b816001141561137b57507e10003203010020002002200030330000100020300002001003030000100202610366565b81600214156113ab57507f3000002000310000040022000010000000100013430002033100300200000302610366565b81600314156113db57507f1103103010020000102000000400320031030100023000004000300000000000610366565b6040805162461bcd60e51b81526020600482015260136024820152722120a22fa4a22c2fa6a0a82fa9a2a1aa24a7a760691b604482015290519081900360640190fd5b3b151590565b60008085851115611433578182fd5b8386111561143f578182fd5b505082019391909203915056fe537461726b576172655f50657270657475616c546f6b656e73416e6452616d70696e675f323032325f324d4953504c414345445f494e4445585f4f525f4241445f434f4e54524143545f4944537461726b576172655f50657270657475616c466f72636564416374696f6e735f323032325f32a2646970667358221220b5b3ad47c772145dec9bfe5706d5cc61a680d96f1c8548c5c12091418f1ba96d64736f6c634300060c0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.