Source Code
Overview
ETH Balance
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 2458320 | 702 days ago | 0.0002 ETH | ||||
| 2458320 | 702 days ago | 0 ETH | ||||
| 2458315 | 702 days ago | 0.0002 ETH | ||||
| 2458315 | 702 days ago | 0 ETH | ||||
| 2458308 | 702 days ago | 0.00155503 ETH | ||||
| 2458308 | 702 days ago | 0 ETH | ||||
| 2458302 | 702 days ago | 0 ETH | ||||
| 2458288 | 702 days ago | 0.0026647 ETH | ||||
| 2458288 | 702 days ago | 0 ETH | ||||
| 2458283 | 702 days ago | 0 ETH | ||||
| 2458282 | 702 days ago | 0.0026647 ETH | ||||
| 2458282 | 702 days ago | 0 ETH | ||||
| 2458282 | 702 days ago | 0 ETH | ||||
| 2458281 | 702 days ago | 0 ETH | ||||
| 2458280 | 702 days ago | 0.0026647 ETH | ||||
| 2458280 | 702 days ago | 0 ETH | ||||
| 2458265 | 702 days ago | 0 ETH | ||||
| 2458264 | 702 days ago | 0.00155794 ETH | ||||
| 2458264 | 702 days ago | 0 ETH | ||||
| 2458248 | 702 days ago | 0.0026647 ETH | ||||
| 2458248 | 702 days ago | 0 ETH | ||||
| 2458229 | 702 days ago | 0.00119385 ETH | ||||
| 2458229 | 702 days ago | 0 ETH | ||||
| 2458211 | 702 days ago | 0.0026647 ETH | ||||
| 2458211 | 702 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ZKBridge
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./libraries/RLPReader.sol";
import "./libraries/BytesLib.sol";
import "./interfaces/IZKBridgeReceiver.sol";
import "./interfaces/IZKBridge.sol";
import "./interfaces/IMptVerifier.sol";
import "./interfaces/IBlockUpdater.sol";
contract ZKBridge is Initializable, OwnableUpgradeable, IZKBridge {
using RLPReader for RLPReader.RLPItem;
using RLPReader for bytes;
using BytesLib for bytes;
event SetFee(uint16 dstChainId, uint256 fee);
event ClaimFee(address operator, uint256 amount);
event SetTrustedRemoteAddress(uint16 chainId, address remoteAddress);
event SetMptVerifier(uint16 chainId, address mptVerifier);
event SetBlockUpdater(uint16 chainId, address lockUpdater);
event SetFeeManager(address feeManager, bool flag);
bytes32 public constant MESSAGE_TOPIC = 0xb8abfd5c33667c7440a4fc1153ae39a24833dbe44f7eb19cbe5cd5f2583e4940;
uint16 public chainId;
// chainId => mptVerifierAddress
mapping(uint16 => IMptVerifier) public mptVerifiers;
// chainId => blockUpdaterAddress
mapping(uint16 => IBlockUpdater) public blockUpdaters;
mapping(bytes32 => uint64) public targetNonce;
// chainId => zkBridgeAddress
mapping(uint16 => address) public trustedRemoteLookup;
mapping(bytes32 => bool) public completedTransfers;
mapping(uint16 => uint256) public fees;
mapping(address => bool) public feeManager;
struct LogMessage {
uint16 dstChainId;
uint64 nonce;
address dstAddress;
address srcAddress;
address srcZkBridge;
bytes payload;
}
struct Payload {
uint16 srcChainId;
uint16 dstChainId;
address srcAddress;
address dstAddress;
uint64 nonce;
bytes uaPayload;
}
modifier onlyFeeManager() {
require(feeManager[msg.sender], "ZKBridge:caller is not the fee manager");
_;
}
function initialize(uint16 _chainId) public initializer {
__Ownable_init();
chainId = _chainId;
}
function send(
uint16 _dstChainId,
address _dstAddress,
bytes memory _payload
) external payable returns (uint64 currentNonce) {
require(_dstChainId != chainId, "ZKBridge:Cannot send to same chain");
require(msg.value >= _estimateFee(_dstChainId), "ZKBridge:insufficient Fee");
currentNonce = _useNonce(msg.sender, _dstChainId, _dstAddress);
emit MessagePublished(msg.sender, _dstChainId, currentNonce, _dstAddress, _payload);
}
function validateTransactionProof(
uint16 _srcChainId,
bytes32 _srcBlockHash,
uint256 _logIndex,
bytes calldata _mptProof
) external {
IMptVerifier mptVerifier = mptVerifiers[_srcChainId];
IBlockUpdater blockUpdater = blockUpdaters[_srcChainId];
require(address(mptVerifier) != address(0), "ZKBridge:MptVerifier is not set");
require(address(blockUpdater) != address(0), "ZKBridge:Block Updater is not set");
IMptVerifier.Receipt memory receipt = mptVerifier.validateMPT(_mptProof);
require(receipt.state == 1, "ZKBridge:Source Chain Transaction Failure");
require(blockUpdater.checkBlock(_srcBlockHash, receipt.receiptHash), "ZKBridge:Block Header is not set");
LogMessage memory logMessage = _parseLog(receipt.logs, _logIndex);
require(
logMessage.srcZkBridge == trustedRemoteLookup[_srcChainId],
"ZKBridge:Destination chain is not a trusted sourcee"
);
require(logMessage.dstChainId == chainId, "ZKBridge:Invalid destination chain");
bytes32 hash = keccak256(
abi.encode(_srcChainId, logMessage.srcAddress, logMessage.dstAddress, logMessage.nonce)
);
require(!completedTransfers[hash], "ZKBridge:Message already executed.");
completedTransfers[hash] = true;
IZKBridgeReceiver(logMessage.dstAddress).zkReceive(
_srcChainId,
logMessage.srcAddress,
logMessage.nonce,
logMessage.payload
);
emit ExecutedMessage(
logMessage.srcAddress,
_srcChainId,
logMessage.nonce,
logMessage.dstAddress,
logMessage.payload
);
}
function _useNonce(
address _emitter,
uint16 _dstChainId,
address _dstAddress
) internal returns (uint64 currentNonce) {
bytes32 hash = keccak256(abi.encode(_emitter, _dstChainId, _dstAddress));
currentNonce = targetNonce[hash];
targetNonce[hash]++;
}
function _parseLog(bytes memory _logsByte, uint256 _logIndex) internal pure returns (LogMessage memory logMessage) {
RLPReader.RLPItem[] memory logs = _logsByte.toRlpItem().toList();
if (_logIndex != 0) {
require(logs.length > _logIndex + 2, "ZKBridge:Invalid proof");
logs = logs[_logIndex + 2].toRlpBytes().toRlpItem().toList();
}
RLPReader.RLPItem[] memory topicItem = logs[1].toRlpBytes().toRlpItem().toList();
bytes32 topic = bytes32(topicItem[0].toUint());
if (topic == MESSAGE_TOPIC) {
logMessage.srcZkBridge = logs[0].toAddress();
logMessage.srcAddress = abi.decode(topicItem[1].toBytes(), (address));
logMessage.dstChainId = uint16(topicItem[2].toUint());
logMessage.nonce = uint64(topicItem[3].toUint());
(logMessage.dstAddress, logMessage.payload) = abi.decode(logs[2].toBytes(), (address, bytes));
}
}
function _estimateFee(uint16 _dstChainId) internal view returns (uint256 bridgeFee) {
bridgeFee = fees[_dstChainId];
}
function estimateFee(uint16 _dstChainId) external view returns (uint256 bridgeFee) {
bridgeFee = _estimateFee(_dstChainId);
}
//----------------------------------------------------------------------------------
// onlyFeeManager
function setFee(uint16 _dstChainId, uint256 _fee) public onlyFeeManager {
fees[_dstChainId] = _fee;
emit SetFee(_dstChainId, _fee);
}
function setFee(uint16[] calldata _dstChainId, uint256[] calldata _fee) public onlyFeeManager {
require(_dstChainId.length == _fee.length);
for (uint256 i = 0; i < _dstChainId.length; i++) {
fees[_dstChainId[i]] = _fee[i];
emit SetFee(_dstChainId[i], _fee[i]);
}
}
//----------------------------------------------------------------------------------
// onlyOwner
function setTrustedRemoteAddress(uint16 _remoteChainId, address _remoteAddress) external onlyOwner {
trustedRemoteLookup[_remoteChainId] = _remoteAddress;
emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress);
}
function setMptVerifier(uint16 _chainId, address _mptVerifier) external onlyOwner {
require(_mptVerifier != address(0), "ZKBridge:Zero address");
mptVerifiers[_chainId] = IMptVerifier(_mptVerifier);
emit SetMptVerifier(_chainId, _mptVerifier);
}
function setBlockUpdater(uint16 _chainId, address _blockUpdater) external onlyOwner {
require(_blockUpdater != address(0), "ZKBridge:Zero address");
blockUpdaters[_chainId] = IBlockUpdater(_blockUpdater);
emit SetBlockUpdater(_chainId, _blockUpdater);
}
function setFeeManager(address _feeManager, bool _flag) external onlyOwner {
require(_feeManager != address(0), "ZKBridge:Zero address");
feeManager[_feeManager] = _flag;
emit SetFeeManager(_feeManager, _flag);
}
function claimFees() external onlyOwner {
emit ClaimFee(msg.sender, address(this).balance);
payable(owner()).transfer(address(this).balance);
}
fallback() external payable {
revert("ZKBridge:unsupported");
}
receive() external payable {
revert("ZKBridge:the ZkBridge contract does not accept assets");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IBlockUpdater {
function checkBlock(bytes32 blockHash, bytes32 receiptsRoot) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IMptVerifier {
struct Receipt {
bytes32 receiptHash;
uint256 state;
bytes logs;
}
function validateMPT(bytes memory proof) external view returns (Receipt memory receipt);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IZKBridge {
event MessagePublished(
address indexed sender,
uint16 indexed dstChainId,
uint64 indexed sequence,
address dstAddress,
bytes payload
);
event ExecutedMessage(
address indexed sender,
uint16 indexed srcChainId,
uint64 indexed sequence,
address dstAddress,
bytes payload
);
function send(uint16 dstChainId, address dstAddress, bytes memory payload) external payable returns (uint64 nonce);
function validateTransactionProof(
uint16 srcChainId,
bytes32 srcBlockHash,
uint256 logIndex,
bytes memory mptProof
) external;
function estimateFee(uint16 dstChainId) external view returns (uint256 fee);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IZKBridgeReceiver {
// @notice ZKBridge endpoint will invoke this function to deliver the message on the destination
// @param srcChainId - the source endpoint identifier
// @param srcAddress - the source sending contract address from the source chain
// @param sequence - the ordered message nonce
// @param payload - the signed payload is the UA bytes has encoded to be sent
function zkReceive(uint16 srcChainId, address srcAddress, uint64 sequence, bytes calldata payload) external;
}// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.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 {
uint len;
uint memPtr;
}
struct Iterator {
RLPItem item; // Item that's being iterated over.
uint 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));
uint ptr = self.nextPtr;
uint 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) {
uint memPtr;
assembly {
memPtr := add(item, 0x20)
}
// offset the pointer if the first byte
uint8 byte0;
assembly {
byte0 := byte(0, mload(memPtr))
}
uint len = item.length;
if (len > 0 && byte0 < LIST_SHORT_START) {
assembly {
memPtr := add(memPtr, 0x01)
}
len -= 1;
}
return RLPItem(len, 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));
uint ptr = self.memPtr + _payloadOffset(self.memPtr);
return Iterator(self, ptr);
}
/*
* @param the RLP item.
*/
function rlpLen(RLPItem memory item) internal pure returns (uint) {
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 (uint, uint) {
uint offset = _payloadOffset(item.memPtr);
uint memPtr = item.memPtr + offset;
uint len = item.len - offset; // data length
return (memPtr, len);
}
/*
* @param the RLP item.
*/
function payloadLen(RLPItem memory item) internal pure returns (uint) {
(, uint 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));
uint items = numItems(item);
RLPItem[] memory result = new RLPItem[](items);
uint memPtr = item.memPtr + _payloadOffset(item.memPtr);
uint dataLen;
for (uint 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;
uint 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) {
(uint memPtr, uint 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;
uint 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);
uint result;
uint 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 (uint) {
require(item.len > 0 && item.len <= 33);
(uint memPtr, uint len) = payloadLocation(item);
uint result;
assembly {
result := mload(memPtr)
// shfit 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 (uint) {
// one byte prefix
require(item.len == 33);
uint result;
uint memPtr = item.memPtr + 1;
assembly {
result := mload(memPtr)
}
return result;
}
function toBytes(RLPItem memory item) internal pure returns (bytes memory) {
require(item.len > 0);
(uint memPtr, uint len) = payloadLocation(item);
bytes memory result = new bytes(len);
uint 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 (uint) {
if (item.len == 0) return 0;
uint count = 0;
uint currPtr = item.memPtr + _payloadOffset(item.memPtr);
uint 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(uint memPtr) private pure returns (uint) {
uint itemLen;
uint 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(uint memPtr) private pure returns (uint) {
uint 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(uint src, uint dest, uint 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
uint 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))
}
}
}
function toBytes32(RLPItem memory self) internal pure returns (bytes32 data) {
return bytes32(toUint(self));
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":true,"internalType":"uint64","name":"sequence","type":"uint64"},{"indexed":false,"internalType":"address","name":"dstAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"}],"name":"ExecutedMessage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint16","name":"dstChainId","type":"uint16"},{"indexed":true,"internalType":"uint64","name":"sequence","type":"uint64"},{"indexed":false,"internalType":"address","name":"dstAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"}],"name":"MessagePublished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"address","name":"lockUpdater","type":"address"}],"name":"SetBlockUpdater","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"SetFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeManager","type":"address"},{"indexed":false,"internalType":"bool","name":"flag","type":"bool"}],"name":"SetFeeManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"address","name":"mptVerifier","type":"address"}],"name":"SetMptVerifier","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"address","name":"remoteAddress","type":"address"}],"name":"SetTrustedRemoteAddress","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"MESSAGE_TOPIC","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"blockUpdaters","outputs":[{"internalType":"contract IBlockUpdater","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"chainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"completedTransfers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"}],"name":"estimateFee","outputs":[{"internalType":"uint256","name":"bridgeFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"fees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"mptVerifiers","outputs":[{"internalType":"contract IMptVerifier","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"address","name":"_dstAddress","type":"address"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"send","outputs":[{"internalType":"uint64","name":"currentNonce","type":"uint64"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"_blockUpdater","type":"address"}],"name":"setBlockUpdater","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"_dstChainId","type":"uint16[]"},{"internalType":"uint256[]","name":"_fee","type":"uint256[]"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeManager","type":"address"},{"internalType":"bool","name":"_flag","type":"bool"}],"name":"setFeeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"_mptVerifier","type":"address"}],"name":"setMptVerifier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"address","name":"_remoteAddress","type":"address"}],"name":"setTrustedRemoteAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"targetNonce","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes32","name":"_srcBlockHash","type":"bytes32"},{"internalType":"uint256","name":"_logIndex","type":"uint256"},{"internalType":"bytes","name":"_mptProof","type":"bytes"}],"name":"validateTransactionProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608060405234801561001057600080fd5b5061242a806100206000396000f3fe6080604052600436106101445760003560e01c806380765130116100b6578063bc22e4bc1161006f578063bc22e4bc146104d2578063c314cdae146104ff578063c7f0da1314610535578063ce19556a14610555578063d294f09314610575578063f2fde38b1461058a576101b4565b806380765130146103e3578063813d31c9146104235780638da5cb5b14610443578063927dd240146104615780639a8a059214610491578063b1d995dd146104bf576101b4565b806346a9c1e51161010857806346a9c1e5146102ea5780634f64ca191461030a578063715018a61461032a57806372ee3f691461033f5780637533d7881461038d5780637cf5744f146103c3576101b4565b8063074f8685146101f35780631375094614610246578063207bae8a1461026857806320d2837d146102965780633fe3da36146102b6576101b4565b366101b45760405162461bcd60e51b815260206004820152603560248201527f5a4b4272696467653a746865205a6b42726964676520636f6e747261637420646044820152746f6573206e6f74206163636570742061737365747360581b60648201526084015b60405180910390fd5b60405162461bcd60e51b81526020600482015260146024820152731692d09c9a5919d94e9d5b9cdd5c1c1bdc9d195960621b60448201526064016101ab565b3480156101ff57600080fd5b5061022961020e366004611bd7565b6068602052600090815260409020546001600160401b031681565b6040516001600160401b0390911681526020015b60405180910390f35b34801561025257600080fd5b50610266610261366004611c07565b6105aa565b005b34801561027457600080fd5b50610288610283366004611c07565b6106ce565b60405190815260200161023d565b3480156102a257600080fd5b506102666102b1366004611c37565b6106e9565b3480156102c257600080fd5b506102887fb8abfd5c33667c7440a4fc1153ae39a24833dbe44f7eb19cbe5cd5f2583e494081565b3480156102f657600080fd5b50610266610305366004611cb9565b610755565b34801561031657600080fd5b50610266610325366004611d24565b61088b565b34801561033657600080fd5b50610266610df3565b34801561034b57600080fd5b5061037561035a366004611c07565b6067602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161023d565b34801561039957600080fd5b506103756103a8366004611c07565b6069602052600090815260409020546001600160a01b031681565b3480156103cf57600080fd5b506102666103de366004611c37565b610e07565b3480156103ef57600080fd5b506104136103fe366004611db7565b606c6020526000908152604090205460ff1681565b604051901515815260200161023d565b34801561042f57600080fd5b5061026661043e366004611c37565b610e99565b34801561044f57600080fd5b506033546001600160a01b0316610375565b34801561046d57600080fd5b5061041361047c366004611bd7565b606a6020526000908152604090205460ff1681565b34801561049d57600080fd5b506065546104ac9061ffff1681565b60405161ffff909116815260200161023d565b6102296104cd366004611e41565b610f2b565b3480156104de57600080fd5b506102886104ed366004611c07565b606b6020526000908152604090205481565b34801561050b57600080fd5b5061037561051a366004611c07565b6066602052600090815260409020546001600160a01b031681565b34801561054157600080fd5b50610266610550366004611ee3565b61105b565b34801561056157600080fd5b50610266610570366004611f1b565b6110d6565b34801561058157600080fd5b50610266611160565b34801561059657600080fd5b506102666105a5366004611db7565b6111dc565b600054610100900460ff16158080156105ca5750600054600160ff909116105b806105e45750303b1580156105e4575060005460ff166001145b6106475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101ab565b6000805460ff19166001179055801561066a576000805461ff0019166101001790555b610672611252565b6065805461ffff191661ffff841617905580156106ca576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b61ffff81166000908152606b60205260408120545b92915050565b6106f1611281565b61ffff821660008181526069602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527ffaf6f43fc2c7c31da89dab02a8c756e6f9cb07101aac8268ce100037170d9cc591016106c1565b336000908152606c602052604090205460ff166107845760405162461bcd60e51b81526004016101ab90611f49565b82811461079057600080fd5b60005b83811015610884578282828181106107ad576107ad611f8f565b90506020020135606b60008787858181106107ca576107ca611f8f565b90506020020160208101906107df9190611c07565b61ffff1681526020810191909152604001600020557f47d9066e07019286c19790aa54f97c9830127e71edff41b453c7adeaa15d2fe885858381811061082757610827611f8f565b905060200201602081019061083c9190611c07565b84848481811061084e5761084e611f8f565b6040805161ffff90951685526020918202939093013590840152500160405180910390a18061087c81611fbb565b915050610793565b5050505050565b61ffff85166000908152606660209081526040808320546067909252909120546001600160a01b039182169116816109055760405162461bcd60e51b815260206004820152601f60248201527f5a4b4272696467653a4d70745665726966696572206973206e6f74207365740060448201526064016101ab565b6001600160a01b0381166109655760405162461bcd60e51b815260206004820152602160248201527f5a4b4272696467653a426c6f636b2055706461746572206973206e6f742073656044820152601d60fa1b60648201526084016101ab565b60405163057d916d60e11b81526000906001600160a01b03841690630afb22da906109969088908890600401611fd4565b600060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109db919081019061206c565b90508060200151600114610a435760405162461bcd60e51b815260206004820152602960248201527f5a4b4272696467653a536f7572636520436861696e205472616e73616374696f6044820152686e204661696c75726560b81b60648201526084016101ab565b8051604051636e1ac47560e11b81526001600160a01b0384169163dc3588ea91610a7a918b91600401918252602082015260400190565b602060405180830381865afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb9190612104565b610b075760405162461bcd60e51b815260206004820181905260248201527f5a4b4272696467653a426c6f636b20486561646572206973206e6f742073657460448201526064016101ab565b6000610b178260400151886112db565b61ffff8a1660009081526069602052604090205460808201519192506001600160a01b03918216911614610ba95760405162461bcd60e51b815260206004820152603360248201527f5a4b4272696467653a44657374696e6174696f6e20636861696e206973206e6f604482015272742061207472757374656420736f757263656560681b60648201526084016101ab565b606554815161ffff908116911614610c0e5760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a496e76616c69642064657374696e6174696f6e2063686160448201526134b760f11b60648201526084016101ab565b600089826060015183604001518460200151604051602001610c62949392919061ffff9490941684526001600160a01b039283166020850152911660408301526001600160401b0316606082015260800190565b60408051601f1981840301815291815281516020928301206000818152606a90935291205490915060ff1615610ce55760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a4d65737361676520616c72656164792065786563757465604482015261321760f11b60648201526084016101ab565b6001606a600083815260200190815260200160002060006101000a81548160ff02191690831515021790555081604001516001600160a01b0316632de9952a8b846060015185602001518660a001516040518563ffffffff1660e01b8152600401610d53949392919061214d565b600060405180830381600087803b158015610d6d57600080fd5b505af1158015610d81573d6000803e3d6000fd5b5050505081602001516001600160401b03168a61ffff1683606001516001600160a01b03167f4a008ac830958ba6fe8a6e667e2ab53a530eb6cdf93e55b27fc42d7a54cf25b785604001518660a00151604051610ddf929190612194565b60405180910390a450505050505050505050565b610dfb611281565b610e056000611527565b565b610e0f611281565b6001600160a01b038116610e355760405162461bcd60e51b81526004016101ab906121b8565b61ffff821660008181526066602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527fed9c939d1df4ba98f2bed2c3925ea9a064ead1c18bee6cbd8872425e3beb979891016106c1565b610ea1611281565b6001600160a01b038116610ec75760405162461bcd60e51b81526004016101ab906121b8565b61ffff821660008181526067602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527fe3e6f58279db3007bfc2c2ede323a50a39329bc9d06e14a32d2def2181ecd22391016106c1565b60655460009061ffff90811690851603610f925760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a43616e6e6f742073656e6420746f2073616d652063686160448201526134b760f11b60648201526084016101ab565b61ffff84166000908152606b6020526040902054341015610ff55760405162461bcd60e51b815260206004820152601960248201527f5a4b4272696467653a696e73756666696369656e74204665650000000000000060448201526064016101ab565b611000338585611579565b9050806001600160401b03168461ffff16336001600160a01b03167fb8abfd5c33667c7440a4fc1153ae39a24833dbe44f7eb19cbe5cd5f2583e4940868660405161104c929190612194565b60405180910390a49392505050565b336000908152606c602052604090205460ff1661108a5760405162461bcd60e51b81526004016101ab90611f49565b61ffff82166000818152606b6020908152604091829020849055815192835282018390527f47d9066e07019286c19790aa54f97c9830127e71edff41b453c7adeaa15d2fe891016106c1565b6110de611281565b6001600160a01b0382166111045760405162461bcd60e51b81526004016101ab906121b8565b6001600160a01b0382166000818152606c6020908152604091829020805460ff19168515159081179091558251938452908301527f882386da003a547e108f4013481dc50dd637ba9e2f89b0a884803db03eef247a91016106c1565b611168611281565b604080513381524760208201527ff40b9ca28516abde647ef8ed0e7b155e16347eb4d8dd6eb29989ed2c0c3d27e8910160405180910390a16033546040516001600160a01b03909116904780156108fc02916000818181858888f193505050501580156111d9573d6000803e3d6000fd5b50565b6111e4611281565b6001600160a01b0381166112495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101ab565b6111d981611527565b600054610100900460ff166112795760405162461bcd60e51b81526004016101ab906121e7565b610e05611616565b6033546001600160a01b03163314610e055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ab565b6040805160c08101825260008082526020820181905291810182905260608082018390526080820183905260a08201529061131d61131885611646565b6116af565b905082156113b257611330836002612232565b8151116113785760405162461bcd60e51b81526020600482015260166024820152752d25a13934b233b29d24b73b30b634b210383937b7b360511b60448201526064016101ab565b6113af6113186113aa8361138d876002612232565b8151811061139d5761139d611f8f565b60200260200101516117c4565b611646565b90505b60006113d06113186113aa8460018151811061139d5761139d611f8f565b905060006113f7826000815181106113ea576113ea611f8f565b6020026020010151611842565b90507f475402a3cc99838bbf5b03eeac51c65db7cc241bb0814e6341a32a0da7c1b6c0810161151e576114438360008151811061143657611436611f8f565b6020026020010151611890565b6001600160a01b031660808501528151611477908390600190811061146a5761146a611f8f565b60200260200101516118aa565b80602001905181019061148a9190612245565b6001600160a01b0316606085015281516114b190839060029081106113ea576113ea611f8f565b61ffff16845281516114d090839060039081106113ea576113ea611f8f565b6001600160401b0316602085015282516114f7908490600290811061146a5761146a611f8f565b80602001905181019061150a9190612262565b60a08601526001600160a01b031660408501525b50505092915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b03808616602083015261ffff8516928201929092529082166060820152600090819060800160408051601f1981840301815291815281516020928301206000818152606890935290822080546001600160401b0316945090925083916115e9836122b2565b91906101000a8154816001600160401b0302191690836001600160401b0316021790555050509392505050565b600054610100900460ff1661163d5760405162461bcd60e51b81526004016101ab906121e7565b610e0533611527565b6040805180820190915260008082526020820152602082018051835160009190911a90801580159061167b575060c060ff8316105b156116935760019283019261169090826122d8565b90505b6040805180820190915290815260208101929092525092915050565b60606116ba82611927565b6116c357600080fd5b60006116ce83611962565b90506000816001600160401b038111156116ea576116ea611dd4565b60405190808252806020026020018201604052801561172f57816020015b60408051808201909152600080825260208201528152602001906001900390816117085790505b509050600061174185602001516119e7565b85602001516117509190612232565b90506000805b848110156117b95761176783611a69565b915060405180604001604052808381526020018481525084828151811061179057611790611f8f565b60209081029190910101526117a58284612232565b9250806117b181611fbb565b915050611756565b509195945050505050565b6060600082600001516001600160401b038111156117e4576117e4611dd4565b6040519080825280601f01601f19166020018201604052801561180e576020820181803683370190505b50905080516000036118205792915050565b600081602001905061183b8460200151828660000151611b0d565b5092915050565b80516000901580159061185757508151602110155b61186057600080fd5b60008061186c84611b90565b8151919350915060208210156118885760208290036101000a90045b949350505050565b80516000906015146118a157600080fd5b6106e382611842565b80516060906118b857600080fd5b6000806118c484611b90565b915091506000816001600160401b038111156118e2576118e2611dd4565b6040519080825280601f01601f19166020018201604052801561190c576020820181803683370190505b5090506020810161191e848285611b0d565b50949350505050565b8051600090810361193a57506000919050565b6020820151805160001a9060c0821015611958575060009392505050565b5060019392505050565b8051600090810361197557506000919050565b60008061198584602001516119e7565b84602001516119949190612232565b90506000846000015185602001516119ac9190612232565b90505b808210156119de576119c082611a69565b6119ca9083612232565b9150826119d681611fbb565b9350506119af565b50909392505050565b8051600090811a6080811015611a005750600092915050565b60b8811080611a1b575060c08110801590611a1b575060f881105b15611a295750600192915050565b60c0811015611a5d57611a3e600160b86122eb565b611a4b9060ff16826122d8565b611a56906001612232565b9392505050565b611a3e600160f86122eb565b80516000908190811a6080811015611a84576001915061183b565b60b8811015611aaa57611a986080826122d8565b611aa3906001612232565b915061183b565b60c0811015611ad75760b78103600185019450806020036101000a8551046001820181019350505061183b565b60f8811015611aeb57611a9860c0826122d8565b60019390930151602084900360f7016101000a900490920160f5190192915050565b80600003611b1a57505050565b60208110611b525782518252611b31602084612232565b9250611b3e602083612232565b9150611b4b6020826122d8565b9050611b1a565b8015611b8b5760006001611b678360206122d8565b611b73906101006123e8565b611b7d91906122d8565b845184518216911916178352505b505050565b6000806000611ba284602001516119e7565b90506000818560200151611bb69190612232565b90506000828660000151611bca91906122d8565b9196919550909350505050565b600060208284031215611be957600080fd5b5035919050565b803561ffff81168114611c0257600080fd5b919050565b600060208284031215611c1957600080fd5b611a5682611bf0565b6001600160a01b03811681146111d957600080fd5b60008060408385031215611c4a57600080fd5b611c5383611bf0565b91506020830135611c6381611c22565b809150509250929050565b60008083601f840112611c8057600080fd5b5081356001600160401b03811115611c9757600080fd5b6020830191508360208260051b8501011115611cb257600080fd5b9250929050565b60008060008060408587031215611ccf57600080fd5b84356001600160401b0380821115611ce657600080fd5b611cf288838901611c6e565b90965094506020870135915080821115611d0b57600080fd5b50611d1887828801611c6e565b95989497509550505050565b600080600080600060808688031215611d3c57600080fd5b611d4586611bf0565b9450602086013593506040860135925060608601356001600160401b0380821115611d6f57600080fd5b818801915088601f830112611d8357600080fd5b813581811115611d9257600080fd5b896020828501011115611da457600080fd5b9699959850939650602001949392505050565b600060208284031215611dc957600080fd5b8135611a5681611c22565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611e1257611e12611dd4565b604052919050565b60006001600160401b03821115611e3357611e33611dd4565b50601f01601f191660200190565b600080600060608486031215611e5657600080fd5b611e5f84611bf0565b92506020840135611e6f81611c22565b915060408401356001600160401b03811115611e8a57600080fd5b8401601f81018613611e9b57600080fd5b8035611eae611ea982611e1a565b611dea565b818152876020838501011115611ec357600080fd5b816020840160208301376000602083830101528093505050509250925092565b60008060408385031215611ef657600080fd5b611eff83611bf0565b946020939093013593505050565b80151581146111d957600080fd5b60008060408385031215611f2e57600080fd5b8235611f3981611c22565b91506020830135611c6381611f0d565b60208082526026908201527f5a4b4272696467653a63616c6c6572206973206e6f742074686520666565206d60408201526530b730b3b2b960d11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611fcd57611fcd611fa5565b5060010190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60005b8381101561201e578181015183820152602001612006565b50506000910152565b600082601f83011261203857600080fd5b8151612046611ea982611e1a565b81815284602083860101111561205b57600080fd5b611888826020830160208701612003565b60006020828403121561207e57600080fd5b81516001600160401b038082111561209557600080fd5b90830190606082860312156120a957600080fd5b6040516060810181811083821117156120c4576120c4611dd4565b806040525082518152602083015160208201526040830151828111156120e957600080fd5b6120f587828601612027565b60408301525095945050505050565b60006020828403121561211657600080fd5b8151611a5681611f0d565b60008151808452612139816020860160208601612003565b601f01601f19169290920160200192915050565b61ffff851681526001600160a01b03841660208201526001600160401b038316604082015260806060820181905260009061218a90830184612121565b9695505050505050565b6001600160a01b038316815260406020820181905260009061188890830184612121565b6020808252601590820152745a4b4272696467653a5a65726f206164647265737360581b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b808201808211156106e3576106e3611fa5565b60006020828403121561225757600080fd5b8151611a5681611c22565b6000806040838503121561227557600080fd5b825161228081611c22565b60208401519092506001600160401b0381111561229c57600080fd5b6122a885828601612027565b9150509250929050565b60006001600160401b038083168181036122ce576122ce611fa5565b6001019392505050565b818103818111156106e3576106e3611fa5565b60ff82811682821603908111156106e3576106e3611fa5565b600181815b8085111561233f57816000190482111561232557612325611fa5565b8085161561233257918102915b93841c9390800290612309565b509250929050565b600082612356575060016106e3565b81612363575060006106e3565b816001811461237957600281146123835761239f565b60019150506106e3565b60ff84111561239457612394611fa5565b50506001821b6106e3565b5060208310610133831016604e8410600b84101617156123c2575081810a6106e3565b6123cc8383612304565b80600019048211156123e0576123e0611fa5565b029392505050565b6000611a56838361234756fea2646970667358221220a8d620fc77f5b5d73a6f06ec74b47d5c1aadf9d478c07fc3232f36c73badc33764736f6c63430008130033
Deployed Bytecode
0x6080604052600436106101445760003560e01c806380765130116100b6578063bc22e4bc1161006f578063bc22e4bc146104d2578063c314cdae146104ff578063c7f0da1314610535578063ce19556a14610555578063d294f09314610575578063f2fde38b1461058a576101b4565b806380765130146103e3578063813d31c9146104235780638da5cb5b14610443578063927dd240146104615780639a8a059214610491578063b1d995dd146104bf576101b4565b806346a9c1e51161010857806346a9c1e5146102ea5780634f64ca191461030a578063715018a61461032a57806372ee3f691461033f5780637533d7881461038d5780637cf5744f146103c3576101b4565b8063074f8685146101f35780631375094614610246578063207bae8a1461026857806320d2837d146102965780633fe3da36146102b6576101b4565b366101b45760405162461bcd60e51b815260206004820152603560248201527f5a4b4272696467653a746865205a6b42726964676520636f6e747261637420646044820152746f6573206e6f74206163636570742061737365747360581b60648201526084015b60405180910390fd5b60405162461bcd60e51b81526020600482015260146024820152731692d09c9a5919d94e9d5b9cdd5c1c1bdc9d195960621b60448201526064016101ab565b3480156101ff57600080fd5b5061022961020e366004611bd7565b6068602052600090815260409020546001600160401b031681565b6040516001600160401b0390911681526020015b60405180910390f35b34801561025257600080fd5b50610266610261366004611c07565b6105aa565b005b34801561027457600080fd5b50610288610283366004611c07565b6106ce565b60405190815260200161023d565b3480156102a257600080fd5b506102666102b1366004611c37565b6106e9565b3480156102c257600080fd5b506102887fb8abfd5c33667c7440a4fc1153ae39a24833dbe44f7eb19cbe5cd5f2583e494081565b3480156102f657600080fd5b50610266610305366004611cb9565b610755565b34801561031657600080fd5b50610266610325366004611d24565b61088b565b34801561033657600080fd5b50610266610df3565b34801561034b57600080fd5b5061037561035a366004611c07565b6067602052600090815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200161023d565b34801561039957600080fd5b506103756103a8366004611c07565b6069602052600090815260409020546001600160a01b031681565b3480156103cf57600080fd5b506102666103de366004611c37565b610e07565b3480156103ef57600080fd5b506104136103fe366004611db7565b606c6020526000908152604090205460ff1681565b604051901515815260200161023d565b34801561042f57600080fd5b5061026661043e366004611c37565b610e99565b34801561044f57600080fd5b506033546001600160a01b0316610375565b34801561046d57600080fd5b5061041361047c366004611bd7565b606a6020526000908152604090205460ff1681565b34801561049d57600080fd5b506065546104ac9061ffff1681565b60405161ffff909116815260200161023d565b6102296104cd366004611e41565b610f2b565b3480156104de57600080fd5b506102886104ed366004611c07565b606b6020526000908152604090205481565b34801561050b57600080fd5b5061037561051a366004611c07565b6066602052600090815260409020546001600160a01b031681565b34801561054157600080fd5b50610266610550366004611ee3565b61105b565b34801561056157600080fd5b50610266610570366004611f1b565b6110d6565b34801561058157600080fd5b50610266611160565b34801561059657600080fd5b506102666105a5366004611db7565b6111dc565b600054610100900460ff16158080156105ca5750600054600160ff909116105b806105e45750303b1580156105e4575060005460ff166001145b6106475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016101ab565b6000805460ff19166001179055801561066a576000805461ff0019166101001790555b610672611252565b6065805461ffff191661ffff841617905580156106ca576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a15b5050565b61ffff81166000908152606b60205260408120545b92915050565b6106f1611281565b61ffff821660008181526069602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527ffaf6f43fc2c7c31da89dab02a8c756e6f9cb07101aac8268ce100037170d9cc591016106c1565b336000908152606c602052604090205460ff166107845760405162461bcd60e51b81526004016101ab90611f49565b82811461079057600080fd5b60005b83811015610884578282828181106107ad576107ad611f8f565b90506020020135606b60008787858181106107ca576107ca611f8f565b90506020020160208101906107df9190611c07565b61ffff1681526020810191909152604001600020557f47d9066e07019286c19790aa54f97c9830127e71edff41b453c7adeaa15d2fe885858381811061082757610827611f8f565b905060200201602081019061083c9190611c07565b84848481811061084e5761084e611f8f565b6040805161ffff90951685526020918202939093013590840152500160405180910390a18061087c81611fbb565b915050610793565b5050505050565b61ffff85166000908152606660209081526040808320546067909252909120546001600160a01b039182169116816109055760405162461bcd60e51b815260206004820152601f60248201527f5a4b4272696467653a4d70745665726966696572206973206e6f74207365740060448201526064016101ab565b6001600160a01b0381166109655760405162461bcd60e51b815260206004820152602160248201527f5a4b4272696467653a426c6f636b2055706461746572206973206e6f742073656044820152601d60fa1b60648201526084016101ab565b60405163057d916d60e11b81526000906001600160a01b03841690630afb22da906109969088908890600401611fd4565b600060405180830381865afa1580156109b3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109db919081019061206c565b90508060200151600114610a435760405162461bcd60e51b815260206004820152602960248201527f5a4b4272696467653a536f7572636520436861696e205472616e73616374696f6044820152686e204661696c75726560b81b60648201526084016101ab565b8051604051636e1ac47560e11b81526001600160a01b0384169163dc3588ea91610a7a918b91600401918252602082015260400190565b602060405180830381865afa158015610a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abb9190612104565b610b075760405162461bcd60e51b815260206004820181905260248201527f5a4b4272696467653a426c6f636b20486561646572206973206e6f742073657460448201526064016101ab565b6000610b178260400151886112db565b61ffff8a1660009081526069602052604090205460808201519192506001600160a01b03918216911614610ba95760405162461bcd60e51b815260206004820152603360248201527f5a4b4272696467653a44657374696e6174696f6e20636861696e206973206e6f604482015272742061207472757374656420736f757263656560681b60648201526084016101ab565b606554815161ffff908116911614610c0e5760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a496e76616c69642064657374696e6174696f6e2063686160448201526134b760f11b60648201526084016101ab565b600089826060015183604001518460200151604051602001610c62949392919061ffff9490941684526001600160a01b039283166020850152911660408301526001600160401b0316606082015260800190565b60408051601f1981840301815291815281516020928301206000818152606a90935291205490915060ff1615610ce55760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a4d65737361676520616c72656164792065786563757465604482015261321760f11b60648201526084016101ab565b6001606a600083815260200190815260200160002060006101000a81548160ff02191690831515021790555081604001516001600160a01b0316632de9952a8b846060015185602001518660a001516040518563ffffffff1660e01b8152600401610d53949392919061214d565b600060405180830381600087803b158015610d6d57600080fd5b505af1158015610d81573d6000803e3d6000fd5b5050505081602001516001600160401b03168a61ffff1683606001516001600160a01b03167f4a008ac830958ba6fe8a6e667e2ab53a530eb6cdf93e55b27fc42d7a54cf25b785604001518660a00151604051610ddf929190612194565b60405180910390a450505050505050505050565b610dfb611281565b610e056000611527565b565b610e0f611281565b6001600160a01b038116610e355760405162461bcd60e51b81526004016101ab906121b8565b61ffff821660008181526066602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527fed9c939d1df4ba98f2bed2c3925ea9a064ead1c18bee6cbd8872425e3beb979891016106c1565b610ea1611281565b6001600160a01b038116610ec75760405162461bcd60e51b81526004016101ab906121b8565b61ffff821660008181526067602090815260409182902080546001600160a01b0319166001600160a01b0386169081179091558251938452908301527fe3e6f58279db3007bfc2c2ede323a50a39329bc9d06e14a32d2def2181ecd22391016106c1565b60655460009061ffff90811690851603610f925760405162461bcd60e51b815260206004820152602260248201527f5a4b4272696467653a43616e6e6f742073656e6420746f2073616d652063686160448201526134b760f11b60648201526084016101ab565b61ffff84166000908152606b6020526040902054341015610ff55760405162461bcd60e51b815260206004820152601960248201527f5a4b4272696467653a696e73756666696369656e74204665650000000000000060448201526064016101ab565b611000338585611579565b9050806001600160401b03168461ffff16336001600160a01b03167fb8abfd5c33667c7440a4fc1153ae39a24833dbe44f7eb19cbe5cd5f2583e4940868660405161104c929190612194565b60405180910390a49392505050565b336000908152606c602052604090205460ff1661108a5760405162461bcd60e51b81526004016101ab90611f49565b61ffff82166000818152606b6020908152604091829020849055815192835282018390527f47d9066e07019286c19790aa54f97c9830127e71edff41b453c7adeaa15d2fe891016106c1565b6110de611281565b6001600160a01b0382166111045760405162461bcd60e51b81526004016101ab906121b8565b6001600160a01b0382166000818152606c6020908152604091829020805460ff19168515159081179091558251938452908301527f882386da003a547e108f4013481dc50dd637ba9e2f89b0a884803db03eef247a91016106c1565b611168611281565b604080513381524760208201527ff40b9ca28516abde647ef8ed0e7b155e16347eb4d8dd6eb29989ed2c0c3d27e8910160405180910390a16033546040516001600160a01b03909116904780156108fc02916000818181858888f193505050501580156111d9573d6000803e3d6000fd5b50565b6111e4611281565b6001600160a01b0381166112495760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016101ab565b6111d981611527565b600054610100900460ff166112795760405162461bcd60e51b81526004016101ab906121e7565b610e05611616565b6033546001600160a01b03163314610e055760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101ab565b6040805160c08101825260008082526020820181905291810182905260608082018390526080820183905260a08201529061131d61131885611646565b6116af565b905082156113b257611330836002612232565b8151116113785760405162461bcd60e51b81526020600482015260166024820152752d25a13934b233b29d24b73b30b634b210383937b7b360511b60448201526064016101ab565b6113af6113186113aa8361138d876002612232565b8151811061139d5761139d611f8f565b60200260200101516117c4565b611646565b90505b60006113d06113186113aa8460018151811061139d5761139d611f8f565b905060006113f7826000815181106113ea576113ea611f8f565b6020026020010151611842565b90507f475402a3cc99838bbf5b03eeac51c65db7cc241bb0814e6341a32a0da7c1b6c0810161151e576114438360008151811061143657611436611f8f565b6020026020010151611890565b6001600160a01b031660808501528151611477908390600190811061146a5761146a611f8f565b60200260200101516118aa565b80602001905181019061148a9190612245565b6001600160a01b0316606085015281516114b190839060029081106113ea576113ea611f8f565b61ffff16845281516114d090839060039081106113ea576113ea611f8f565b6001600160401b0316602085015282516114f7908490600290811061146a5761146a611f8f565b80602001905181019061150a9190612262565b60a08601526001600160a01b031660408501525b50505092915050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b03808616602083015261ffff8516928201929092529082166060820152600090819060800160408051601f1981840301815291815281516020928301206000818152606890935290822080546001600160401b0316945090925083916115e9836122b2565b91906101000a8154816001600160401b0302191690836001600160401b0316021790555050509392505050565b600054610100900460ff1661163d5760405162461bcd60e51b81526004016101ab906121e7565b610e0533611527565b6040805180820190915260008082526020820152602082018051835160009190911a90801580159061167b575060c060ff8316105b156116935760019283019261169090826122d8565b90505b6040805180820190915290815260208101929092525092915050565b60606116ba82611927565b6116c357600080fd5b60006116ce83611962565b90506000816001600160401b038111156116ea576116ea611dd4565b60405190808252806020026020018201604052801561172f57816020015b60408051808201909152600080825260208201528152602001906001900390816117085790505b509050600061174185602001516119e7565b85602001516117509190612232565b90506000805b848110156117b95761176783611a69565b915060405180604001604052808381526020018481525084828151811061179057611790611f8f565b60209081029190910101526117a58284612232565b9250806117b181611fbb565b915050611756565b509195945050505050565b6060600082600001516001600160401b038111156117e4576117e4611dd4565b6040519080825280601f01601f19166020018201604052801561180e576020820181803683370190505b50905080516000036118205792915050565b600081602001905061183b8460200151828660000151611b0d565b5092915050565b80516000901580159061185757508151602110155b61186057600080fd5b60008061186c84611b90565b8151919350915060208210156118885760208290036101000a90045b949350505050565b80516000906015146118a157600080fd5b6106e382611842565b80516060906118b857600080fd5b6000806118c484611b90565b915091506000816001600160401b038111156118e2576118e2611dd4565b6040519080825280601f01601f19166020018201604052801561190c576020820181803683370190505b5090506020810161191e848285611b0d565b50949350505050565b8051600090810361193a57506000919050565b6020820151805160001a9060c0821015611958575060009392505050565b5060019392505050565b8051600090810361197557506000919050565b60008061198584602001516119e7565b84602001516119949190612232565b90506000846000015185602001516119ac9190612232565b90505b808210156119de576119c082611a69565b6119ca9083612232565b9150826119d681611fbb565b9350506119af565b50909392505050565b8051600090811a6080811015611a005750600092915050565b60b8811080611a1b575060c08110801590611a1b575060f881105b15611a295750600192915050565b60c0811015611a5d57611a3e600160b86122eb565b611a4b9060ff16826122d8565b611a56906001612232565b9392505050565b611a3e600160f86122eb565b80516000908190811a6080811015611a84576001915061183b565b60b8811015611aaa57611a986080826122d8565b611aa3906001612232565b915061183b565b60c0811015611ad75760b78103600185019450806020036101000a8551046001820181019350505061183b565b60f8811015611aeb57611a9860c0826122d8565b60019390930151602084900360f7016101000a900490920160f5190192915050565b80600003611b1a57505050565b60208110611b525782518252611b31602084612232565b9250611b3e602083612232565b9150611b4b6020826122d8565b9050611b1a565b8015611b8b5760006001611b678360206122d8565b611b73906101006123e8565b611b7d91906122d8565b845184518216911916178352505b505050565b6000806000611ba284602001516119e7565b90506000818560200151611bb69190612232565b90506000828660000151611bca91906122d8565b9196919550909350505050565b600060208284031215611be957600080fd5b5035919050565b803561ffff81168114611c0257600080fd5b919050565b600060208284031215611c1957600080fd5b611a5682611bf0565b6001600160a01b03811681146111d957600080fd5b60008060408385031215611c4a57600080fd5b611c5383611bf0565b91506020830135611c6381611c22565b809150509250929050565b60008083601f840112611c8057600080fd5b5081356001600160401b03811115611c9757600080fd5b6020830191508360208260051b8501011115611cb257600080fd5b9250929050565b60008060008060408587031215611ccf57600080fd5b84356001600160401b0380821115611ce657600080fd5b611cf288838901611c6e565b90965094506020870135915080821115611d0b57600080fd5b50611d1887828801611c6e565b95989497509550505050565b600080600080600060808688031215611d3c57600080fd5b611d4586611bf0565b9450602086013593506040860135925060608601356001600160401b0380821115611d6f57600080fd5b818801915088601f830112611d8357600080fd5b813581811115611d9257600080fd5b896020828501011115611da457600080fd5b9699959850939650602001949392505050565b600060208284031215611dc957600080fd5b8135611a5681611c22565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611e1257611e12611dd4565b604052919050565b60006001600160401b03821115611e3357611e33611dd4565b50601f01601f191660200190565b600080600060608486031215611e5657600080fd5b611e5f84611bf0565b92506020840135611e6f81611c22565b915060408401356001600160401b03811115611e8a57600080fd5b8401601f81018613611e9b57600080fd5b8035611eae611ea982611e1a565b611dea565b818152876020838501011115611ec357600080fd5b816020840160208301376000602083830101528093505050509250925092565b60008060408385031215611ef657600080fd5b611eff83611bf0565b946020939093013593505050565b80151581146111d957600080fd5b60008060408385031215611f2e57600080fd5b8235611f3981611c22565b91506020830135611c6381611f0d565b60208082526026908201527f5a4b4272696467653a63616c6c6572206973206e6f742074686520666565206d60408201526530b730b3b2b960d11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611fcd57611fcd611fa5565b5060010190565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60005b8381101561201e578181015183820152602001612006565b50506000910152565b600082601f83011261203857600080fd5b8151612046611ea982611e1a565b81815284602083860101111561205b57600080fd5b611888826020830160208701612003565b60006020828403121561207e57600080fd5b81516001600160401b038082111561209557600080fd5b90830190606082860312156120a957600080fd5b6040516060810181811083821117156120c4576120c4611dd4565b806040525082518152602083015160208201526040830151828111156120e957600080fd5b6120f587828601612027565b60408301525095945050505050565b60006020828403121561211657600080fd5b8151611a5681611f0d565b60008151808452612139816020860160208601612003565b601f01601f19169290920160200192915050565b61ffff851681526001600160a01b03841660208201526001600160401b038316604082015260806060820181905260009061218a90830184612121565b9695505050505050565b6001600160a01b038316815260406020820181905260009061188890830184612121565b6020808252601590820152745a4b4272696467653a5a65726f206164647265737360581b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b808201808211156106e3576106e3611fa5565b60006020828403121561225757600080fd5b8151611a5681611c22565b6000806040838503121561227557600080fd5b825161228081611c22565b60208401519092506001600160401b0381111561229c57600080fd5b6122a885828601612027565b9150509250929050565b60006001600160401b038083168181036122ce576122ce611fa5565b6001019392505050565b818103818111156106e3576106e3611fa5565b60ff82811682821603908111156106e3576106e3611fa5565b600181815b8085111561233f57816000190482111561232557612325611fa5565b8085161561233257918102915b93841c9390800290612309565b509250929050565b600082612356575060016106e3565b81612363575060006106e3565b816001811461237957600281146123835761239f565b60019150506106e3565b60ff84111561239457612394611fa5565b50506001821b6106e3565b5060208310610133831016604e8410600b84101617156123c2575081810a6106e3565b6123cc8383612304565b80600019048211156123e0576123e0611fa5565b029392505050565b6000611a56838361234756fea2646970667358221220a8d620fc77f5b5d73a6f06ec74b47d5c1aadf9d478c07fc3232f36c73badc33764736f6c63430008130033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
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.