Sepolia Testnet

Contract

0xc6755144d60548f3DD420F47Cf48DAe553bBf042

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Dispatch Blocks68063462024-10-03 10:33:48113 days ago1727951628IN
0xc6755144...553bBf042
0 ETH0.01932938213.88214296
Dispatch Blocks64715992024-08-10 6:25:36167 days ago1723271136IN
0xc6755144...553bBf042
0 ETH0.000380674.21222378
Dispatch Blocks64715452024-08-10 6:13:48167 days ago1723270428IN
0xc6755144...553bBf042
0 ETH0.00040714.5046666
Dispatch Blocks64714922024-08-10 6:02:00167 days ago1723269720IN
0xc6755144...553bBf042
0 ETH0.000338783.74872977
Dispatch Blocks64714392024-08-10 5:50:12167 days ago1723269012IN
0xc6755144...553bBf042
0 ETH0.000459445.08383958
Dispatch Blocks64713862024-08-10 5:37:48167 days ago1723268268IN
0xc6755144...553bBf042
0 ETH0.000357073.95104059
Dispatch Blocks64713322024-08-10 5:25:36167 days ago1723267536IN
0xc6755144...553bBf042
0 ETH0.000228432.52770709
Dispatch Blocks64712202024-08-10 5:01:36167 days ago1723266096IN
0xc6755144...553bBf042
0 ETH0.000247472.73834705
Dispatch Blocks64711142024-08-10 4:37:36167 days ago1723264656IN
0xc6755144...553bBf042
0 ETH0.0003433.79543982
Dispatch Blocks64710632024-08-10 4:25:36167 days ago1723263936IN
0xc6755144...553bBf042
0 ETH0.000237932.63278655
Dispatch Blocks64710092024-08-10 4:13:36167 days ago1723263216IN
0xc6755144...553bBf042
0 ETH0.000412314.56226491
Dispatch Blocks64709602024-08-10 4:01:36167 days ago1723262496IN
0xc6755144...553bBf042
0 ETH0.000195522.16353456
Dispatch Blocks64709062024-08-10 3:49:36167 days ago1723261776IN
0xc6755144...553bBf042
0 ETH0.000265822.94133283
Dispatch Blocks64708542024-08-10 3:37:36167 days ago1723261056IN
0xc6755144...553bBf042
0 ETH0.000160411.77503494
Dispatch Blocks64708022024-08-10 3:25:48167 days ago1723260348IN
0xc6755144...553bBf042
0 ETH0.000169621.87692467
Dispatch Blocks64707482024-08-10 3:13:36167 days ago1723259616IN
0xc6755144...553bBf042
0 ETH0.000125041.3836508
Dispatch Blocks64706952024-08-10 3:01:36167 days ago1723258896IN
0xc6755144...553bBf042
0 ETH0.00007480.82772476
Dispatch Blocks64706402024-08-10 2:49:36167 days ago1723258176IN
0xc6755144...553bBf042
0 ETH0.000102161.13052404
Dispatch Blocks64705862024-08-10 2:37:36167 days ago1723257456IN
0xc6755144...553bBf042
0 ETH0.000151681.67844401
Dispatch Blocks64705312024-08-10 2:25:36167 days ago1723256736IN
0xc6755144...553bBf042
0 ETH0.000186552.06420963
Dispatch Blocks64704802024-08-10 2:13:36167 days ago1723256016IN
0xc6755144...553bBf042
0 ETH0.000116941.29404077
Dispatch Blocks64704312024-08-10 2:02:00167 days ago1723255320IN
0xc6755144...553bBf042
0 ETH0.000175591.94302325
Dispatch Blocks64703812024-08-10 1:49:48167 days ago1723254588IN
0xc6755144...553bBf042
0 ETH0.000159371.76355591
Dispatch Blocks64703242024-08-10 1:37:36167 days ago1723253856IN
0xc6755144...553bBf042
0 ETH0.000411814.55679787
Dispatch Blocks64702722024-08-10 1:25:36167 days ago1723253136IN
0xc6755144...553bBf042
0 ETH0.000544796.02817709
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AMBReporter

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 10000 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 11 : AMBReporter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

import { Reporter } from "../Reporter.sol";
import { AMBAdapter } from "./AMBAdapter.sol";
import { IAdapter } from "../../interfaces/IAdapter.sol";
import { IAMB } from "./IAMB.sol";

contract AMBReporter is Reporter {
    string public constant PROVIDER = "amb";

    address public immutable AMB;
    uint256 public immutable GAS;
    uint256 public immutable TARGET_CHAIN_ID;

    error InvalidToChainId(uint256 chainId, uint256 expectedChainId);

    constructor(
        address headerStorage,
        address yaho,
        address amb,
        uint256 targetChainId,
        uint256 gas
    ) Reporter(headerStorage, yaho) {
        AMB = amb;
        TARGET_CHAIN_ID = targetChainId;
        GAS = gas;
    }

    function _dispatch(
        uint256 targetChainId,
        address adapter,
        uint256[] memory ids,
        bytes32[] memory hashes
    ) internal override returns (bytes32) {
        if (targetChainId != TARGET_CHAIN_ID) revert InvalidToChainId(targetChainId, TARGET_CHAIN_ID);
        bytes memory payload = abi.encodeCall(AMBAdapter.storeHashes, (ids, hashes));
        return IAMB(AMB).requireToPassMessage(adapter, payload, GAS);
    }
}

File 2 of 11 : Adapter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

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

abstract contract Adapter is IAdapter {
    mapping(uint256 => mapping(uint256 => bytes32)) private _hashes;

    /// @inheritdoc IAdapter
    function getHash(uint256 domain, uint256 id) public view returns (bytes32) {
        return _hashes[domain][id];
    }

    function _storeHashes(uint256 domain, uint256[] memory ids, bytes32[] memory hashes) internal {
        for (uint256 i = 0; i < ids.length; ) {
            _storeHash(domain, ids[i], hashes[i]);
            unchecked {
                ++i;
            }
        }
    }

    function _storeHash(uint256 domain, uint256 id, bytes32 hash) internal {
        bytes32 currentHash = _hashes[domain][id];
        if (currentHash != hash) {
            _hashes[domain][id] = hash;
            emit HashStored(id, hash);
        }
    }
}

File 3 of 11 : AMBAdapter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

import { IAMB } from "./IAMB.sol";
import { BlockHashAdapter } from "../BlockHashAdapter.sol";

contract AMBAdapter is BlockHashAdapter {
    string public constant PROVIDER = "amb";

    IAMB public immutable AMB;
    address public immutable REPORTER;
    bytes32 public immutable SOURCE_CHAIN_ID;

    error ArrayLengthMissmatch();
    error UnauthorizedAMB(address sender, address expectedSender);
    error UnauthorizedChainId(bytes32 sourceChainId, bytes32 expectedSourceChainId);
    error UnauthorizedHashReporter(address reporter, address expectedReporter);

    constructor(address amb, address reporter, bytes32 sourceChainId) {
        AMB = IAMB(amb);
        REPORTER = reporter;
        SOURCE_CHAIN_ID = sourceChainId;
    }

    modifier onlyValid() {
        bytes32 ambSourceChainId = AMB.messageSourceChainId();
        address ambMessageSender = AMB.messageSender();
        if (msg.sender != address(AMB)) revert UnauthorizedAMB(msg.sender, address(AMB));
        if (ambSourceChainId != SOURCE_CHAIN_ID) revert UnauthorizedChainId(ambSourceChainId, SOURCE_CHAIN_ID);
        if (ambMessageSender != REPORTER) revert UnauthorizedHashReporter(ambMessageSender, REPORTER);
        _;
    }

    function storeHashes(uint256[] memory ids, bytes32[] memory _hashes) public onlyValid {
        if (ids.length != _hashes.length) revert ArrayLengthMissmatch();
        _storeHashes(uint256(SOURCE_CHAIN_ID), ids, _hashes);
    }
}

File 4 of 11 : IAMB.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

interface IAMB {
    function messageSender() external view returns (address);

    function messageSourceChainId() external view returns (bytes32);

    function requireToPassMessage(address _contract, bytes memory _data, uint256 _gas) external returns (bytes32);
}

File 5 of 11 : BlockHashAdapter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

import { RLPReader } from "solidity-rlp/contracts/RLPReader.sol";
import { Adapter } from "./Adapter.sol";
import { IBlockHashAdapter } from "../interfaces/IBlockHashAdapter.sol";

abstract contract BlockHashAdapter is IBlockHashAdapter, Adapter {
    using RLPReader for RLPReader.RLPItem;

    /// @inheritdoc IBlockHashAdapter
    function proveAncestralBlockHashes(uint256 chainId, bytes[] memory blockHeaders) external {
        for (uint256 i = 0; i < blockHeaders.length; i++) {
            RLPReader.RLPItem memory blockHeaderRLP = RLPReader.toRlpItem(blockHeaders[i]);

            if (!blockHeaderRLP.isList()) revert InvalidBlockHeaderRLP();

            RLPReader.RLPItem[] memory blockHeaderContent = blockHeaderRLP.toList();

            // A block header should have between 15 and 17 elements (baseFee and withdrawalsRoot have been added later)
            if (blockHeaderContent.length < 15 || blockHeaderContent.length > 17)
                revert InvalidBlockHeaderLength(blockHeaderContent.length);

            bytes32 blockParent = bytes32(blockHeaderContent[0].toUint());
            uint256 blockNumber = uint256(blockHeaderContent[8].toUint());

            bytes32 blockHash = keccak256(blockHeaders[i]);
            bytes32 storedBlockHash = getHash(chainId, blockNumber);

            if (blockHash != storedBlockHash) revert ConflictingBlockHeader(blockNumber, blockHash, storedBlockHash);

            _storeHash(chainId, blockNumber - 1, blockParent);
        }
    }
}

File 6 of 11 : Reporter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.20;

import { IHeaderStorage } from "../interfaces/IHeaderStorage.sol";
import { IReporter } from "../interfaces/IReporter.sol";
import { IAdapter } from "../interfaces/IAdapter.sol";

abstract contract Reporter is IReporter {
    address public immutable HEADER_STORAGE;
    address public immutable YAHO;

    modifier onlyYaho() {
        if (msg.sender != YAHO) revert NotYaho(msg.sender, YAHO);
        _;
    }

    constructor(address headerStorage, address yaho) {
        HEADER_STORAGE = headerStorage;
        YAHO = yaho;
    }

    /// @inheritdoc IReporter
    function dispatchBlocks(
        uint256 targetChainId,
        IAdapter adapter,
        uint256[] memory blockNumbers
    ) external payable returns (bytes32) {
        bytes32[] memory blockHeaders = IHeaderStorage(HEADER_STORAGE).storeBlockHeaders(blockNumbers);
        for (uint256 i = 0; i < blockNumbers.length; ) {
            emit BlockDispatched(targetChainId, adapter, blockNumbers[i], blockHeaders[i]);
            unchecked {
                ++i;
            }
        }
        return _dispatch(targetChainId, address(adapter), blockNumbers, blockHeaders);
    }

    /// @inheritdoc IReporter
    function dispatchMessages(
        uint256 targetChainId,
        IAdapter adapter,
        uint256[] memory messageIds,
        bytes32[] memory messageHashes
    ) external payable onlyYaho returns (bytes32) {
        for (uint256 i = 0; i < messageIds.length; ) {
            emit MessageDispatched(targetChainId, adapter, messageIds[i], messageHashes[i]);
            unchecked {
                ++i;
            }
        }
        return _dispatch(targetChainId, address(adapter), messageIds, messageHashes);
    }

    function _dispatch(
        uint256 targetChainId,
        address adapter,
        uint256[] memory ids,
        bytes32[] memory hashes
    ) internal virtual returns (bytes32);
}

File 7 of 11 : 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 8 of 11 : IBlockHashAdapter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

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

/**
 * @title IBlockHashAdapter
 */
interface IBlockHashAdapter is IAdapter {
    /**
     * @dev Proves and stores valid ancestral block hashes for a given chain ID.
     * @param chainId - The ID of the chain to prove block hashes for.
     * @param blockHeaders - The RLP encoded block headers to prove the hashes for.
     * @notice Block headers should be ordered by descending block number and should start with a known block header.
     */
    function proveAncestralBlockHashes(uint256 chainId, bytes[] memory blockHeaders) external;
}

File 9 of 11 : IHeaderStorage.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

/**
 * @title IHeaderStorage
 */
interface IHeaderStorage {
    error HeaderOutOfRange(uint256 blockNumber);

    /**
     * @dev Emitted when a block header is stored.
     * @param blockNumber - The block number associated with the stored header.
     * @param blockHeader - The stored block header as a bytes32 value.
     */
    event HeaderStored(uint256 indexed blockNumber, bytes32 indexed blockHeader);

    /**
     * @dev Retrieves the stored block header for a specific block number.
     * @param blockNumber - The block number as a uint256 value.
     * @return The block header as a bytes32 value.
     */
    function headers(uint256 blockNumber) external view returns (bytes32);

    /**
     * @dev Stores and returns the header for the given block.
     * @param blockNumber - Block number.
     * @return blockHeader - Block header stored.
     * @notice Reverts if the given block header was not previously stored and is now out of range.
     */
    function storeBlockHeader(uint256 blockNumber) external returns (bytes32);

    /**
     * @dev Stores and returns the header for an array of given blocks.
     * @param blockNumbers - Array of block numbers.
     * @return blockHeaders - Array of block headers stored.
     * @notice Reverts if the given block header was not previously stored and is now out of range.
     */
    function storeBlockHeaders(uint256[] memory blockNumbers) external returns (bytes32[] memory);
}

File 10 of 11 : IReporter.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.0;

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

interface IReporter {
    error NotYaho(address sender, address expectedYaho);

    /**
     * @dev Emitted when a block is dispatched to another chain.
     * @param targetChainId - The target chain's identifier associated with the dispatched block.
     * @param adapter - The adapter address associated with the dispatched block.
     * @param blockNumber - The block number associated with the dispatched block.
     * @param blockHeader - The dispatched block header as a bytes32 value.
     */
    event BlockDispatched(
        uint256 indexed targetChainId,
        IAdapter adapter,
        uint256 indexed blockNumber,
        bytes32 blockHeader
    );

    /**
     * @dev Emitted when a message is dispatched to another chain.
     * @param targetChainId - The target chain's identifier associated with the dispatched message.
     * @param adapter - The adapter address associated with the dispatched message.
     * @param messageId - The message identifier associated with the dispatched message.
     * @param messageHash - The dispatched message hash as a bytes32 value.
     */
    event MessageDispatched(
        uint256 indexed targetChainId,
        IAdapter adapter,
        uint256 indexed messageId,
        bytes32 messageHash
    );

    /**
     * @dev Dispatches blocks to a given adapter on the target chaib.
     * @param targetChainId - The target chain's Uint256 identifier.
     * @param adapter - The adapter instance to use.
     * @param blockNumbers - An array of Uint256 block numbers to dispatch.
     * @notice blockNumbers must include block numbers that are greater than or equal to (currentBlock - 256) due to EVM limitations.
     * @return result - The result returned by the adapter as bytes.
     */
    function dispatchBlocks(
        uint256 targetChainId,
        IAdapter adapter,
        uint256[] memory blockNumbers
    ) external payable returns (bytes32);

    /**
     * @dev Dispatches messages to a target chain using the specified adapter.
     * @param targetChainId - The target chain's Uint256 identifier.
     * @param adapter - The adapter instance to use.
     * @param messageIds - An array of Uint256 message identifiers.
     * @param messageHashes - An array of bytes32 message hashes.
     * @notice This function can be called only by Yaho
     * @return result - The result returned by the adapter as bytes.
     */
    function dispatchMessages(
        uint256 targetChainId,
        IAdapter adapter,
        uint256[] memory messageIds,
        bytes32[] memory messageHashes
    ) external payable returns (bytes32);
}

File 11 of 11 : RLPReader.sol
// SPDX-License-Identifier: Apache-2.0

/*
 * @author Hamdi Allam [email protected]
 * Please reach out with any questions or concerns
 */
pragma solidity >=0.5.10 <0.9.0;

library RLPReader {
    uint8 constant STRING_SHORT_START = 0x80;
    uint8 constant STRING_LONG_START = 0xb8;
    uint8 constant LIST_SHORT_START = 0xc0;
    uint8 constant LIST_LONG_START = 0xf8;
    uint8 constant WORD_SIZE = 32;

    struct RLPItem {
        uint256 len;
        uint256 memPtr;
    }

    struct Iterator {
        RLPItem item; // Item that's being iterated over.
        uint256 nextPtr; // Position of the next item in the list.
    }

    /*
     * @dev Returns the next element in the iteration. Reverts if it has not next element.
     * @param self The iterator.
     * @return The next element in the iteration.
     */
    function next(Iterator memory self) internal pure returns (RLPItem memory) {
        require(hasNext(self));

        uint256 ptr = self.nextPtr;
        uint256 itemLength = _itemLength(ptr);
        self.nextPtr = ptr + itemLength;

        return RLPItem(itemLength, ptr);
    }

    /*
     * @dev Returns true if the iteration has more elements.
     * @param self The iterator.
     * @return true if the iteration has more elements.
     */
    function hasNext(Iterator memory self) internal pure returns (bool) {
        RLPItem memory item = self.item;
        return self.nextPtr < item.memPtr + item.len;
    }

    /*
     * @param item RLP encoded bytes
     */
    function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) {
        uint256 memPtr;
        assembly {
            memPtr := add(item, 0x20)
        }

        return RLPItem(item.length, memPtr);
    }

    /*
     * @dev Create an iterator. Reverts if item is not a list.
     * @param self The RLP item.
     * @return An 'Iterator' over the item.
     */
    function iterator(RLPItem memory self) internal pure returns (Iterator memory) {
        require(isList(self));

        uint256 ptr = self.memPtr + _payloadOffset(self.memPtr);
        return Iterator(self, ptr);
    }

    /*
     * @param the RLP item.
     */
    function rlpLen(RLPItem memory item) internal pure returns (uint256) {
        return item.len;
    }

    /*
     * @param the RLP item.
     * @return (memPtr, len) pair: location of the item's payload in memory.
     */
    function payloadLocation(RLPItem memory item) internal pure returns (uint256, uint256) {
        uint256 offset = _payloadOffset(item.memPtr);
        uint256 memPtr = item.memPtr + offset;
        uint256 len = item.len - offset; // data length
        return (memPtr, len);
    }

    /*
     * @param the RLP item.
     */
    function payloadLen(RLPItem memory item) internal pure returns (uint256) {
        (, uint256 len) = payloadLocation(item);
        return len;
    }

    /*
     * @param the RLP item containing the encoded list.
     */
    function toList(RLPItem memory item) internal pure returns (RLPItem[] memory) {
        require(isList(item));

        uint256 items = numItems(item);
        RLPItem[] memory result = new RLPItem[](items);

        uint256 memPtr = item.memPtr + _payloadOffset(item.memPtr);
        uint256 dataLen;
        for (uint256 i = 0; i < items; i++) {
            dataLen = _itemLength(memPtr);
            result[i] = RLPItem(dataLen, memPtr);
            memPtr = memPtr + dataLen;
        }

        return result;
    }

    // @return indicator whether encoded payload is a list. negate this function call for isData.
    function isList(RLPItem memory item) internal pure returns (bool) {
        if (item.len == 0) return false;

        uint8 byte0;
        uint256 memPtr = item.memPtr;
        assembly {
            byte0 := byte(0, mload(memPtr))
        }

        if (byte0 < LIST_SHORT_START) return false;
        return true;
    }

    /*
     * @dev A cheaper version of keccak256(toRlpBytes(item)) that avoids copying memory.
     * @return keccak256 hash of RLP encoded bytes.
     */
    function rlpBytesKeccak256(RLPItem memory item) internal pure returns (bytes32) {
        uint256 ptr = item.memPtr;
        uint256 len = item.len;
        bytes32 result;
        assembly {
            result := keccak256(ptr, len)
        }
        return result;
    }

    /*
     * @dev A cheaper version of keccak256(toBytes(item)) that avoids copying memory.
     * @return keccak256 hash of the item payload.
     */
    function payloadKeccak256(RLPItem memory item) internal pure returns (bytes32) {
        (uint256 memPtr, uint256 len) = payloadLocation(item);
        bytes32 result;
        assembly {
            result := keccak256(memPtr, len)
        }
        return result;
    }

    /** RLPItem conversions into data types **/

    // @returns raw rlp encoding in bytes
    function toRlpBytes(RLPItem memory item) internal pure returns (bytes memory) {
        bytes memory result = new bytes(item.len);
        if (result.length == 0) return result;

        uint256 ptr;
        assembly {
            ptr := add(0x20, result)
        }

        copy(item.memPtr, ptr, item.len);
        return result;
    }

    // any non-zero byte except "0x80" is considered true
    function toBoolean(RLPItem memory item) internal pure returns (bool) {
        require(item.len == 1);
        uint256 result;
        uint256 memPtr = item.memPtr;
        assembly {
            result := byte(0, mload(memPtr))
        }

        // SEE Github Issue #5.
        // Summary: Most commonly used RLP libraries (i.e Geth) will encode
        // "0" as "0x80" instead of as "0". We handle this edge case explicitly
        // here.
        if (result == 0 || result == STRING_SHORT_START) {
            return false;
        } else {
            return true;
        }
    }

    function toAddress(RLPItem memory item) internal pure returns (address) {
        // 1 byte for the length prefix
        require(item.len == 21);

        return address(uint160(toUint(item)));
    }

    function toUint(RLPItem memory item) internal pure returns (uint256) {
        require(item.len > 0 && item.len <= 33);

        (uint256 memPtr, uint256 len) = payloadLocation(item);

        uint256 result;
        assembly {
            result := mload(memPtr)

            // shift to the correct location if neccesary
            if lt(len, 32) {
                result := div(result, exp(256, sub(32, len)))
            }
        }

        return result;
    }

    // enforces 32 byte length
    function toUintStrict(RLPItem memory item) internal pure returns (uint256) {
        // one byte prefix
        require(item.len == 33);

        uint256 result;
        uint256 memPtr = item.memPtr + 1;
        assembly {
            result := mload(memPtr)
        }

        return result;
    }

    function toBytes(RLPItem memory item) internal pure returns (bytes memory) {
        require(item.len > 0);

        (uint256 memPtr, uint256 len) = payloadLocation(item);
        bytes memory result = new bytes(len);

        uint256 destPtr;
        assembly {
            destPtr := add(0x20, result)
        }

        copy(memPtr, destPtr, len);
        return result;
    }

    /*
     * Private Helpers
     */

    // @return number of payload items inside an encoded list.
    function numItems(RLPItem memory item) private pure returns (uint256) {
        if (item.len == 0) return 0;

        uint256 count = 0;
        uint256 currPtr = item.memPtr + _payloadOffset(item.memPtr);
        uint256 endPtr = item.memPtr + item.len;
        while (currPtr < endPtr) {
            currPtr = currPtr + _itemLength(currPtr); // skip over an item
            count++;
        }

        return count;
    }

    // @return entire rlp item byte length
    function _itemLength(uint256 memPtr) private pure returns (uint256) {
        uint256 itemLen;
        uint256 byte0;
        assembly {
            byte0 := byte(0, mload(memPtr))
        }

        if (byte0 < STRING_SHORT_START) {
            itemLen = 1;
        } else if (byte0 < STRING_LONG_START) {
            itemLen = byte0 - STRING_SHORT_START + 1;
        } else if (byte0 < LIST_SHORT_START) {
            assembly {
                let byteLen := sub(byte0, 0xb7) // # of bytes the actual length is
                memPtr := add(memPtr, 1) // skip over the first byte

                /* 32 byte word size */
                let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to get the len
                itemLen := add(dataLen, add(byteLen, 1))
            }
        } else if (byte0 < LIST_LONG_START) {
            itemLen = byte0 - LIST_SHORT_START + 1;
        } else {
            assembly {
                let byteLen := sub(byte0, 0xf7)
                memPtr := add(memPtr, 1)

                let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to the correct length
                itemLen := add(dataLen, add(byteLen, 1))
            }
        }

        return itemLen;
    }

    // @return number of bytes until the data
    function _payloadOffset(uint256 memPtr) private pure returns (uint256) {
        uint256 byte0;
        assembly {
            byte0 := byte(0, mload(memPtr))
        }

        if (byte0 < STRING_SHORT_START) {
            return 0;
        } else if (byte0 < STRING_LONG_START || (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)) {
            return 1;
        } else if (byte0 < LIST_SHORT_START) {
            // being explicit
            return byte0 - (STRING_LONG_START - 1) + 1;
        } else {
            return byte0 - (LIST_LONG_START - 1) + 1;
        }
    }

    /*
     * @param src Pointer to source
     * @param dest Pointer to destination
     * @param len Amount of memory to copy from the source
     */
    function copy(uint256 src, uint256 dest, uint256 len) private pure {
        if (len == 0) return;

        // copy as many word sizes as possible
        for (; len >= WORD_SIZE; len -= WORD_SIZE) {
            assembly {
                mstore(dest, mload(src))
            }

            src += WORD_SIZE;
            dest += WORD_SIZE;
        }

        if (len > 0) {
            // left over bytes. Mask is used to remove unwanted bytes from the word
            uint256 mask = 256**(WORD_SIZE - len) - 1;
            assembly {
                let srcpart := and(mload(src), not(mask)) // zero out src
                let destpart := and(mload(dest), mask) // retrieve the bytes
                mstore(dest, or(destpart, srcpart))
            }
        }
    }
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"headerStorage","type":"address"},{"internalType":"address","name":"yaho","type":"address"},{"internalType":"address","name":"amb","type":"address"},{"internalType":"uint256","name":"targetChainId","type":"uint256"},{"internalType":"uint256","name":"gas","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"uint256","name":"expectedChainId","type":"uint256"}],"name":"InvalidToChainId","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"expectedYaho","type":"address"}],"name":"NotYaho","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"targetChainId","type":"uint256"},{"indexed":false,"internalType":"contract IAdapter","name":"adapter","type":"address"},{"indexed":true,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"blockHeader","type":"bytes32"}],"name":"BlockDispatched","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"targetChainId","type":"uint256"},{"indexed":false,"internalType":"contract IAdapter","name":"adapter","type":"address"},{"indexed":true,"internalType":"uint256","name":"messageId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"messageHash","type":"bytes32"}],"name":"MessageDispatched","type":"event"},{"inputs":[],"name":"AMB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GAS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HEADER_STORAGE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROVIDER","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TARGET_CHAIN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"YAHO","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"targetChainId","type":"uint256"},{"internalType":"contract IAdapter","name":"adapter","type":"address"},{"internalType":"uint256[]","name":"blockNumbers","type":"uint256[]"}],"name":"dispatchBlocks","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"targetChainId","type":"uint256"},{"internalType":"contract IAdapter","name":"adapter","type":"address"},{"internalType":"uint256[]","name":"messageIds","type":"uint256[]"},{"internalType":"bytes32[]","name":"messageHashes","type":"bytes32[]"}],"name":"dispatchMessages","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"}]

610120346100d957601f610b4338819003918201601f19168301916001600160401b038311848410176100de5780849260a0946040528339810103126100d957610048816100f4565b610054602083016100f4565b610060604084016100f4565b90608060608501519401519260805260a05260c05261010091825260e052604051610a3a918261010983396080518281816103e50152610539015260a0518281816101f3015261032c015260c05182818160a7015261094a015260e051828181610120015261092201525181818160e601526107e20152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036100d95756fe608060408181526004918236101561001657600080fd5b600092833560e01c918262d344111461055d575081631073f93d1461050c5781639ac41b98146103505781639e83334b146102ff578163b4a90ff71461014357508063bb1913f314610109578063c940baf8146100cf5763d69f9d611461007c57600080fd5b346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5080fd5b50346100cb57816003193601126100cb57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b50346100cb57816003193601126100cb57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b90508260806003193601126102fc57813561015c6106c8565b67ffffffffffffffff926044358481116100cb5761017d9036908701610708565b906064359485116102fc57366023860112156102fc5784860135906101a1826106f0565b956101ae895197886105fa565b82875260209260248489019160051b830101913683116102f8576024859101915b8383106102e8575050505073ffffffffffffffffffffffffffffffffffffffff96877f0000000000000000000000000000000000000000000000000000000000000000168033036102b25750505b825181101561029a57806102336001928561079a565b51867fd05d8e0013365e4d441d98e6459477af9dd142c5cf590e87ca927921993b6c62610291610263858c61079a565b518d5173ffffffffffffffffffffffffffffffffffffffff8b16815260208101919091529081906040820190565b0390a30161021d565b5095946102ab9493919216906107dd565b9051908152f35b604492508951917fce98f81500000000000000000000000000000000000000000000000000000000835233908301526024820152fd5b82358152918101918591016101cf565b8380fd5b80fd5b5050346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b83915060606003193601126100cb5780356103696106c8565b67ffffffffffffffff926044358481116105085761038a9036908301610708565b908651957fceee6e5500000000000000000000000000000000000000000000000000000000875260208092880152866103c66024820185610766565b0396818173ffffffffffffffffffffffffffffffffffffffff9981838c7f0000000000000000000000000000000000000000000000000000000000000000165af19687156104fe578297610467575b50505b825181101561029a578061042e6001928561079a565b51867fdfde4db189423e6f919a3d3cb1306e03dc18b4e72bc0c6c13fe07c58b395335c61045e610263858c61079a565b0390a301610418565b909196503d8088843e61047a81846105fa565b82019183818403126104fa5780519182116104fa57019080601f830112156104f65781516104a7816106f0565b926104b48b5194856105fa565b818452848085019260051b8201019283116104f25784809101915b8383106104e25750505050948880610415565b82518152918101918591016104cf565b8880fd5b8680fd5b8780fd5b89513d84823e3d90fd5b8580fd5b5050346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b8385346102fc57806003193601126102fc578183019083821067ffffffffffffffff8311176105ce57506105ca93508152600382527f616d62000000000000000000000000000000000000000000000000000000000060208301525191829160208352602083019061066a565b0390f35b806041867f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761063b57604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b919082519283825260005b8481106106b45750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8460006020809697860101520116010190565b602081830181015184830182015201610675565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036106eb57565b600080fd5b67ffffffffffffffff811161063b5760051b60200190565b81601f820112156106eb5780359161071f836106f0565b9261072d60405194856105fa565b808452602092838086019260051b8201019283116106eb578301905b828210610757575050505090565b81358152908301908301610749565b90815180825260208080930193019160005b828110610786575050505090565b835185529381019392810192600101610778565b80518210156107ae5760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9392937f00000000000000000000000000000000000000000000000000000000000000008082036109cd5750506040516108496020937f69f559030000000000000000000000000000000000000000000000000000000085840152604060248401526064830190610766565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82820301604483015283808751928381520196019060005b8181106109b9575050508291816108c66109209360009798037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826105fa565b6040519586809481937fdc8601b300000000000000000000000000000000000000000000000000000000835273ffffffffffffffffffffffffffffffffffffffff809616600484015260606024840152606483019061066a565b7f0000000000000000000000000000000000000000000000000000000000000000604483015203927f0000000000000000000000000000000000000000000000000000000000000000165af19081156109ad57600091610981575b50905090565b82813d83116109a6575b61099581836105fa565b810103126102fc575051803861097b565b503d61098b565b6040513d6000823e3d90fd5b825188529685019691850191600101610882565b60449250604051917f841022d500000000000000000000000000000000000000000000000000000000835260048301526024820152fdfea2646970667358221220a0f6189416ac8bacbff43b7ce8c9d509ec3b5ac352094d9eb96128da7d6cbe0b64736f6c6343000814003300000000000000000000000048800ebef4491c65b2172d3628ddddc9c47fe43000000000000000000000000021eab033c7d2df6a67aef6c5bda9a7f151eb9f52000000000000000000000000f2546d6648bd2af6a008a7e7c1542bb240329e1100000000000000000000000000000000000000000000000000000000000027d8000000000000000000000000000000000000000000000000000000000007a120

Deployed Bytecode

0x608060408181526004918236101561001657600080fd5b600092833560e01c918262d344111461055d575081631073f93d1461050c5781639ac41b98146103505781639e83334b146102ff578163b4a90ff71461014357508063bb1913f314610109578063c940baf8146100cf5763d69f9d611461007c57600080fd5b346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f2546d6648bd2af6a008a7e7c1542bb240329e11168152f35b5080fd5b50346100cb57816003193601126100cb57602090517f00000000000000000000000000000000000000000000000000000000000027d88152f35b50346100cb57816003193601126100cb57602090517f000000000000000000000000000000000000000000000000000000000007a1208152f35b90508260806003193601126102fc57813561015c6106c8565b67ffffffffffffffff926044358481116100cb5761017d9036908701610708565b906064359485116102fc57366023860112156102fc5784860135906101a1826106f0565b956101ae895197886105fa565b82875260209260248489019160051b830101913683116102f8576024859101915b8383106102e8575050505073ffffffffffffffffffffffffffffffffffffffff96877f00000000000000000000000021eab033c7d2df6a67aef6c5bda9a7f151eb9f52168033036102b25750505b825181101561029a57806102336001928561079a565b51867fd05d8e0013365e4d441d98e6459477af9dd142c5cf590e87ca927921993b6c62610291610263858c61079a565b518d5173ffffffffffffffffffffffffffffffffffffffff8b16815260208101919091529081906040820190565b0390a30161021d565b5095946102ab9493919216906107dd565b9051908152f35b604492508951917fce98f81500000000000000000000000000000000000000000000000000000000835233908301526024820152fd5b82358152918101918591016101cf565b8380fd5b80fd5b5050346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000021eab033c7d2df6a67aef6c5bda9a7f151eb9f52168152f35b83915060606003193601126100cb5780356103696106c8565b67ffffffffffffffff926044358481116105085761038a9036908301610708565b908651957fceee6e5500000000000000000000000000000000000000000000000000000000875260208092880152866103c66024820185610766565b0396818173ffffffffffffffffffffffffffffffffffffffff9981838c7f00000000000000000000000048800ebef4491c65b2172d3628ddddc9c47fe430165af19687156104fe578297610467575b50505b825181101561029a578061042e6001928561079a565b51867fdfde4db189423e6f919a3d3cb1306e03dc18b4e72bc0c6c13fe07c58b395335c61045e610263858c61079a565b0390a301610418565b909196503d8088843e61047a81846105fa565b82019183818403126104fa5780519182116104fa57019080601f830112156104f65781516104a7816106f0565b926104b48b5194856105fa565b818452848085019260051b8201019283116104f25784809101915b8383106104e25750505050948880610415565b82518152918101918591016104cf565b8880fd5b8680fd5b8780fd5b89513d84823e3d90fd5b8580fd5b5050346100cb57816003193601126100cb576020905173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000048800ebef4491c65b2172d3628ddddc9c47fe430168152f35b8385346102fc57806003193601126102fc578183019083821067ffffffffffffffff8311176105ce57506105ca93508152600382527f616d62000000000000000000000000000000000000000000000000000000000060208301525191829160208352602083019061066a565b0390f35b806041867f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761063b57604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b919082519283825260005b8481106106b45750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8460006020809697860101520116010190565b602081830181015184830182015201610675565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036106eb57565b600080fd5b67ffffffffffffffff811161063b5760051b60200190565b81601f820112156106eb5780359161071f836106f0565b9261072d60405194856105fa565b808452602092838086019260051b8201019283116106eb578301905b828210610757575050505090565b81358152908301908301610749565b90815180825260208080930193019160005b828110610786575050505090565b835185529381019392810192600101610778565b80518210156107ae5760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9392937f00000000000000000000000000000000000000000000000000000000000027d88082036109cd5750506040516108496020937f69f559030000000000000000000000000000000000000000000000000000000085840152604060248401526064830190610766565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc82820301604483015283808751928381520196019060005b8181106109b9575050508291816108c66109209360009798037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826105fa565b6040519586809481937fdc8601b300000000000000000000000000000000000000000000000000000000835273ffffffffffffffffffffffffffffffffffffffff809616600484015260606024840152606483019061066a565b7f000000000000000000000000000000000000000000000000000000000007a120604483015203927f000000000000000000000000f2546d6648bd2af6a008a7e7c1542bb240329e11165af19081156109ad57600091610981575b50905090565b82813d83116109a6575b61099581836105fa565b810103126102fc575051803861097b565b503d61098b565b6040513d6000823e3d90fd5b825188529685019691850191600101610882565b60449250604051917f841022d500000000000000000000000000000000000000000000000000000000835260048301526024820152fdfea2646970667358221220a0f6189416ac8bacbff43b7ce8c9d509ec3b5ac352094d9eb96128da7d6cbe0b64736f6c63430008140033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000048800ebef4491c65b2172d3628ddddc9c47fe43000000000000000000000000021eab033c7d2df6a67aef6c5bda9a7f151eb9f52000000000000000000000000f2546d6648bd2af6a008a7e7c1542bb240329e1100000000000000000000000000000000000000000000000000000000000027d8000000000000000000000000000000000000000000000000000000000007a120

-----Decoded View---------------
Arg [0] : headerStorage (address): 0x48800eBEf4491C65b2172d3628DdDDC9c47fe430
Arg [1] : yaho (address): 0x21eAB033C7D2DF6A67AeF6C5Bda9A7F151eB9f52
Arg [2] : amb (address): 0xf2546D6648BD2af6a008A7e7C1542BB240329E11
Arg [3] : targetChainId (uint256): 10200
Arg [4] : gas (uint256): 500000

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000048800ebef4491c65b2172d3628ddddc9c47fe430
Arg [1] : 00000000000000000000000021eab033c7d2df6a67aef6c5bda9a7f151eb9f52
Arg [2] : 000000000000000000000000f2546d6648bd2af6a008a7e7c1542bb240329e11
Arg [3] : 00000000000000000000000000000000000000000000000000000000000027d8
Arg [4] : 000000000000000000000000000000000000000000000000000000000007a120


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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