POL Price: $0.232178 (-0.01%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Hashi

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 10000 runs

Other Settings:
paris EvmVersion
File 1 of 3 : Hashi.sol
/*
                  ███▄▄▄                               ,▄▄███▄
                  ████▀`                      ,╓▄▄▄████████████▄
                  ███▌             ,╓▄▄▄▄█████████▀▀▀▀▀▀╙└`
                  ███▌       ▀▀▀▀▀▀▀▀▀▀╙└└-  ████L
                  ███▌                      ████`               ╓██▄
                  ███▌    ╓▄    ╓╓╓╓╓╓╓╓╓╓╓████▄╓╓╓╓╓╓╓╓╓╓╓╓╓╓▄███████▄
                  ███▌  ▄█████▄ ▀▀▀▀▀▀▀▀▀▀████▀▀▀▀▀▀██▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
         ███████████████████████_       ▄███▀        ██µ
                 ▐███▌                ,███▀           ▀██µ
                 ████▌               ▄███▌,           ▄████▄
                ▐████▌             ▄██▀████▀▀▀▀▀▀▀▀▀▀█████▀███▄
               ,█████▌          ,▄██▀_ ▓███          ▐███_  ▀████▄▄
               ██████▌,       ▄██▀_    ▓███          ▐███_    ▀███████▄-
              ███▀███▌▀███▄  ╙"        ▓███▄▄▄▄▄▄▄▄▄▄▄███_      `▀███└
             ▄██^ ███▌  ^████▄         ▓███▀▀▀▀▀▀▀▀▀▀▀███_         `
            ▄██_  ███▌    ╙███         ▓██▀          └▀▀_        ▄,
           ██▀    ███▌      ▀└ ▐███▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄████▄µ
          ██^     ███▌         ▐███▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀██████▀
        ╓█▀       ███▌         ▐███⌐      µ          ╓          ▐███
        ▀         ███▌         ▐███⌐      ███▄▄▄▄▄▄▄████▄       ▐███
                  ███▌         ▐███⌐      ████▀▀▀▀▀▀▀████▀      ▐███
                  ███▌         ▐███⌐      ███▌      J███M       ▐███
                  ███▌         ▐███⌐      ███▌      J███M       ▐███
                  ███▌         ▐███⌐      ████▄▄▄▄▄▄████M       ▐███
                  ███▌         ▐███⌐      ███▌      ▐███M       ▐███
                  ███▌         ▐███⌐      ███▌       ▀▀_        ████
                  ███▌         ▐███⌐      ▀▀_             ▀▀▀███████
                  ███^         ▐███_                          ▐██▀▀ 

              Made with ❤️ by Gnosis Guild & the Cross-chain Alliance
*/
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

import { IAdapter } from "./interfaces/IAdapter.sol";
import { IHashi } from "./interfaces/IHashi.sol";

contract Hashi is IHashi {
    /// @inheritdoc IHashi
    function checkHashWithThresholdFromAdapters(
        uint256 domain,
        uint256 id,
        uint256 threshold,
        IAdapter[] calldata adapters
    ) external view returns (bool) {
        if (threshold > adapters.length || threshold == 0) revert InvalidThreshold(threshold, adapters.length);
        bytes32[] memory hashes = getHashesFromAdapters(domain, id, adapters);

        for (uint256 i = 0; i < hashes.length; ) {
            if (i > hashes.length - threshold) break;

            bytes32 baseHash = hashes[i];
            if (baseHash == bytes32(0)) {
                unchecked {
                    ++i;
                }
                continue;
            }

            uint256 num = 0;
            for (uint256 j = i; j < hashes.length; ) {
                if (baseHash == hashes[j]) {
                    unchecked {
                        ++num;
                    }
                    if (num == threshold) return true;
                }
                unchecked {
                    ++j;
                }
            }

            unchecked {
                ++i;
            }
        }
        return false;
    }

    /// @inheritdoc IHashi
    function getHashFromAdapter(uint256 domain, uint256 id, IAdapter adapter) external view returns (bytes32) {
        return adapter.getHash(domain, id);
    }

    /// @inheritdoc IHashi
    function getHashesFromAdapters(
        uint256 domain,
        uint256 id,
        IAdapter[] calldata adapters
    ) public view returns (bytes32[] memory) {
        if (adapters.length == 0) revert NoAdaptersGiven();
        bytes32[] memory hashes = new bytes32[](adapters.length);
        for (uint256 i = 0; i < adapters.length; ) {
            hashes[i] = adapters[i].getHash(domain, id);
            unchecked {
                ++i;
            }
        }
        return hashes;
    }

    /// @inheritdoc IHashi
    function getHash(uint256 domain, uint256 id, IAdapter[] calldata adapters) external view returns (bytes32 hash) {
        if (adapters.length == 0) revert NoAdaptersGiven();
        bytes32[] memory hashes = getHashesFromAdapters(domain, id, adapters);
        hash = hashes[0];
        if (hash == bytes32(0)) revert HashNotAvailableInAdapter(adapters[0]);
        for (uint256 i = 1; i < hashes.length; ) {
            if (hashes[i] == bytes32(0)) revert HashNotAvailableInAdapter(adapters[i]);
            if (hash != hashes[i]) revert AdaptersDisagree(adapters[i - 1], adapters[i]);
            unchecked {
                ++i;
            }
        }
    }
}

File 2 of 3 : IAdapter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title IAdapter
 */
interface IAdapter {
    error ConflictingBlockHeader(uint256 blockNumber, bytes32 blockHash, bytes32 storedBlockHash);
    error InvalidBlockHeaderLength(uint256 length);
    error InvalidBlockHeaderRLP();

    /**
     * @dev Emitted when a hash is stored.
     * @param id - The ID of the stored hash.
     * @param hash - The stored hash as bytes32 values.
     */
    event HashStored(uint256 indexed id, bytes32 indexed hash);

    /**
     * @dev Returns the hash for a given ID.
     * @param domain - Identifier for the domain to query.
     * @param id - Identifier for the ID to query.
     * @return hash Bytes32 hash for the given ID on the given domain.
     * @notice MUST return bytes32(0) if the hash is not present.
     */
    function getHash(uint256 domain, uint256 id) external view returns (bytes32 hash);
}

File 3 of 3 : IHashi.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

import { IAdapter } from "./IAdapter.sol";

/**
 * @title IHashi
 */
interface IHashi {
    error AdaptersDisagree(IAdapter adapterOne, IAdapter adapterTwo);
    error HashNotAvailableInAdapter(IAdapter adapter);
    error InvalidThreshold(uint256 threshold, uint256 maxThreshold);
    error NoAdaptersGiven();

    /**
     * @dev Checks whether the threshold is reached for a message given a set of adapters.
     * @param domain - ID of the domain to query.
     * @param id - ID for which to return hash.
     * @param threshold - Threshold to use.
     * @param adapters - Array of addresses for the adapters to query.
     * @notice If the threshold is 1, it will always return true.
     * @return result A boolean indicating if a threshold for a given message has been reached.
     */
    function checkHashWithThresholdFromAdapters(
        uint256 domain,
        uint256 id,
        uint256 threshold,
        IAdapter[] calldata adapters
    ) external view returns (bool);

    /**
     * @dev Returns the hash stored by a given adapter for a given ID.
     * @param domain - ID of the domain to query.
     * @param id - ID for which to return a hash.
     * @param adapter - Address of the adapter to query.
     * @return hash stored by the given adapter for the given ID.
     */
    function getHashFromAdapter(uint256 domain, uint256 id, IAdapter adapter) external view returns (bytes32);

    /**
     * @dev Returns the hashes for a given ID stored by a given set of adapters.
     * @param domain - The ID of the domain to query.
     * @param id - The ID for which to return hashes.
     * @param adapters - An array of addresses for the adapters to query.
     * @return hashes An array of hashes stored by the given adapters for the specified ID.
     */
    function getHashesFromAdapters(
        uint256 domain,
        uint256 id,
        IAdapter[] calldata adapters
    ) external view returns (bytes32[] memory);

    /**
     * @dev Returns the hash unanimously agreed upon by a given set of adapters.
     * @param domain - The ID of the domain to query.
     * @param id - The ID for which to return a hash.
     * @param adapters - An array of addresses for the adapters to query.
     * @return hash agreed on by the given set of adapters.
     * @notice MUST revert if adapters disagree on the hash or if an adapter does not report.
     */
    function getHash(uint256 domain, uint256 id, IAdapter[] calldata adapters) external view returns (bytes32);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IAdapter","name":"adapterOne","type":"address"},{"internalType":"contract IAdapter","name":"adapterTwo","type":"address"}],"name":"AdaptersDisagree","type":"error"},{"inputs":[{"internalType":"contract IAdapter","name":"adapter","type":"address"}],"name":"HashNotAvailableInAdapter","type":"error"},{"inputs":[{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"uint256","name":"maxThreshold","type":"uint256"}],"name":"InvalidThreshold","type":"error"},{"inputs":[],"name":"NoAdaptersGiven","type":"error"},{"inputs":[{"internalType":"uint256","name":"domain","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"contract IAdapter[]","name":"adapters","type":"address[]"}],"name":"checkHashWithThresholdFromAdapters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"domain","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"contract IAdapter[]","name":"adapters","type":"address[]"}],"name":"getHash","outputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"domain","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"contract IAdapter","name":"adapter","type":"address"}],"name":"getHashFromAdapter","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"domain","type":"uint256"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"contract IAdapter[]","name":"adapters","type":"address[]"}],"name":"getHashesFromAdapters","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"}]

6080806040523461001657610872908161001c8239f35b600080fdfe6040608081526004908136101561001557600080fd5b600090813560e01c806354580e44146103dd578063b0bb1be41461036a578063c6eb7e90146102775763ead227541461004d57600080fd5b346102735761005b3661046e565b959286959291951561024b57856100739288926106e9565b9182511561021f5760208301519485156101fd5760019693969384805b61009f575b6020888851908152f35b8897969597518110156101f4576100b6818a6104c3565b51156101a0576100c6818a6104c3565b5187036100d95795969495850185610090565b85917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82018281116101745760449650918161012461011f61012a9561011f95896106b8565b6106c8565b956106b8565b9051927f435065db00000000000000000000000000000000000000000000000000000000845273ffffffffffffffffffffffffffffffffffffffff80931690840152166024820152fd5b6024876011887f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b6101c761011f73ffffffffffffffffffffffffffffffffffffffff926024969489966106b8565b9251927f0bee135d0000000000000000000000000000000000000000000000000000000084521690820152fd5b85969750610095565b60249173ffffffffffffffffffffffffffffffffffffffff6101c787936106c8565b9060326024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b8385517fc77f9c81000000000000000000000000000000000000000000000000000000008152fd5b5080fd5b508290346103505760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610350576044359173ffffffffffffffffffffffffffffffffffffffff83168093036103665760209060448351809581937f1b85504400000000000000000000000000000000000000000000000000000000835280359083015260243560248301525afa91821561035c578392610321575b6020838351908152f35b9091506020813d8211610354575b8161033c60209383610630565b810103126103505760209250519083610317565b8280fd5b3d915061032f565b81513d85823e3d90fd5b8380fd5b5090346103da5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103da576064359067ffffffffffffffff82116103da57506020926103c26103d19236908301610438565b91604435906024359035610506565b90519015158152f35b80fd5b5034610273576103f86103ef3661046e565b929190916106e9565b815192839260208080860192818752855180945286019401925b82811061042157505050500390f35b835185528695509381019392810192600101610412565b9181601f840112156104695782359167ffffffffffffffff8311610469576020808501948460051b01011161046957565b600080fd5b60607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201126104695760043591602435916044359067ffffffffffffffff8211610469576104bf91600401610438565b9091565b80518210156104d75760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b939291938385118015610628575b6105f157906105249392916106e9565b6000915b8151808410156105e8578181039081116105b95783116105b15761054c83836104c3565b5180156105a657600092845b81518110156105985761056b81836104c3565b51831461057b575b600101610558565b60018095019484861461058e5750610573565b9550505050505090565b509250509160010191610528565b509160010191610528565b505050600090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50505050600090565b60448585604051917f7b7a98f100000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b508415610514565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761067157604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116106715760051b60200190565b91908110156104d75760051b0190565b3573ffffffffffffffffffffffffffffffffffffffff811681036104695790565b9190918315610812576106fb846106a0565b9360409361070b85519687610630565b8186527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0610738836106a0565b0191602092368489013760005b818110610756575050505050505090565b60448473ffffffffffffffffffffffffffffffffffffffff61077c61011f85878c6106b8565b168951928380927f1b8550440000000000000000000000000000000000000000000000000000000082528a60048301528860248301525afa908115610807576000916107d9575b50906001916107d2828b6104c3565b5201610745565b908582813d8311610800575b6107ef8183610630565b810103126103da57505160016107c3565b503d6107e5565b88513d6000823e3d90fd5b60046040517fc77f9c81000000000000000000000000000000000000000000000000000000008152fdfea2646970667358221220ace9b3f900b7e4a7f1a5ff375cbb1482ff90396af39cb8ef7e933d2a87b2f4b764736f6c63430008140033

Deployed Bytecode

0x6040608081526004908136101561001557600080fd5b600090813560e01c806354580e44146103dd578063b0bb1be41461036a578063c6eb7e90146102775763ead227541461004d57600080fd5b346102735761005b3661046e565b959286959291951561024b57856100739288926106e9565b9182511561021f5760208301519485156101fd5760019693969384805b61009f575b6020888851908152f35b8897969597518110156101f4576100b6818a6104c3565b51156101a0576100c6818a6104c3565b5187036100d95795969495850185610090565b85917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82018281116101745760449650918161012461011f61012a9561011f95896106b8565b6106c8565b956106b8565b9051927f435065db00000000000000000000000000000000000000000000000000000000845273ffffffffffffffffffffffffffffffffffffffff80931690840152166024820152fd5b6024876011887f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b6101c761011f73ffffffffffffffffffffffffffffffffffffffff926024969489966106b8565b9251927f0bee135d0000000000000000000000000000000000000000000000000000000084521690820152fd5b85969750610095565b60249173ffffffffffffffffffffffffffffffffffffffff6101c787936106c8565b9060326024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b8385517fc77f9c81000000000000000000000000000000000000000000000000000000008152fd5b5080fd5b508290346103505760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610350576044359173ffffffffffffffffffffffffffffffffffffffff83168093036103665760209060448351809581937f1b85504400000000000000000000000000000000000000000000000000000000835280359083015260243560248301525afa91821561035c578392610321575b6020838351908152f35b9091506020813d8211610354575b8161033c60209383610630565b810103126103505760209250519083610317565b8280fd5b3d915061032f565b81513d85823e3d90fd5b8380fd5b5090346103da5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103da576064359067ffffffffffffffff82116103da57506020926103c26103d19236908301610438565b91604435906024359035610506565b90519015158152f35b80fd5b5034610273576103f86103ef3661046e565b929190916106e9565b815192839260208080860192818752855180945286019401925b82811061042157505050500390f35b835185528695509381019392810192600101610412565b9181601f840112156104695782359167ffffffffffffffff8311610469576020808501948460051b01011161046957565b600080fd5b60607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201126104695760043591602435916044359067ffffffffffffffff8211610469576104bf91600401610438565b9091565b80518210156104d75760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b939291938385118015610628575b6105f157906105249392916106e9565b6000915b8151808410156105e8578181039081116105b95783116105b15761054c83836104c3565b5180156105a657600092845b81518110156105985761056b81836104c3565b51831461057b575b600101610558565b60018095019484861461058e5750610573565b9550505050505090565b509250509160010191610528565b509160010191610528565b505050600090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50505050600090565b60448585604051917f7b7a98f100000000000000000000000000000000000000000000000000000000835260048301526024820152fd5b508415610514565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761067157604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116106715760051b60200190565b91908110156104d75760051b0190565b3573ffffffffffffffffffffffffffffffffffffffff811681036104695790565b9190918315610812576106fb846106a0565b9360409361070b85519687610630565b8186527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0610738836106a0565b0191602092368489013760005b818110610756575050505050505090565b60448473ffffffffffffffffffffffffffffffffffffffff61077c61011f85878c6106b8565b168951928380927f1b8550440000000000000000000000000000000000000000000000000000000082528a60048301528860248301525afa908115610807576000916107d9575b50906001916107d2828b6104c3565b5201610745565b908582813d8311610800575b6107ef8183610630565b810103126103da57505160016107c3565b503d6107e5565b88513d6000823e3d90fd5b60046040517fc77f9c81000000000000000000000000000000000000000000000000000000008152fdfea2646970667358221220ace9b3f900b7e4a7f1a5ff375cbb1482ff90396af39cb8ef7e933d2a87b2f4b764736f6c63430008140033

Block Transaction 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

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.