Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ZkStack_CustomGasToken_Adapter
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./interfaces/AdapterInterface.sol";
import "../external/interfaces/WETH9Interface.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { BridgeHubInterface } from "../interfaces/ZkStackBridgeHub.sol";
/**
* @notice Interface for funder contract that this contract pulls from to pay for relayMessage()/relayTokens()
* fees using a custom gas token.
*/
interface FunderInterface {
/**
* @notice Withdraws amount of token from funder contract to the caller.
* @dev Can only be called by owner of Funder contract, which therefore must be
* this contract.
* @param token Token to withdraw.
* @param amount Amount to withdraw.
*/
function withdraw(IERC20 token, uint256 amount) external;
}
/**
* @notice Contract containing logic to send messages from L1 to ZkStack with a custom gas token.
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
* called via delegatecall, which will execute this contract's logic within the context of the originating contract.
* For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
* that call this contract's logic guard against reentrancy.
* @custom:security-contact [email protected]
*/
// solhint-disable-next-line contract-name-camelcase
contract ZkStack_CustomGasToken_Adapter is AdapterInterface {
using SafeERC20 for IERC20;
// The ZkSync bridgehub contract treats address(1) to represent ETH.
address private constant ETH_TOKEN_ADDRESS = address(1);
// We need to pay a base fee to the operator to include our L1 --> L2 transaction.
// https://docs.zksync.io/build/developer-reference/l1-l2-interoperability#l1-to-l2-gas-estimation-for-transactions
// Limit on L2 gas to spend.
uint256 public immutable L2_GAS_LIMIT; // typically 2_000_000
// How much gas is required to publish a byte of data from L1 to L2. 800 is the required value
// as set here https://github.com/matter-labs/era-contracts/blob/6391c0d7bf6184d7f6718060e3991ba6f0efe4a7/ethereum/contracts/zksync/facets/Mailbox.sol#L226
// Note, this value can change and will require an updated adapter.
uint256 public immutable L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT; // Typically 800
// This address receives any remaining fee after an L1 to L2 transaction completes.
// If refund recipient = address(0) then L2 msg.sender is used, unless msg.sender is a contract then its address
// gets aliased.
address public immutable L2_REFUND_ADDRESS;
// L2 chain id
uint256 public immutable CHAIN_ID;
// BridgeHub address
BridgeHubInterface public immutable BRIDGE_HUB;
// Set l1Weth at construction time to make testing easier.
WETH9Interface public immutable L1_WETH;
// SharedBridge address, which is read from the BridgeHub at construction.
address public immutable SHARED_BRIDGE;
// Custom gas token address, which is read from the BridgeHub at construction.
address public immutable CUSTOM_GAS_TOKEN;
// Custom gas token funder
FunderInterface public immutable CUSTOM_GAS_TOKEN_FUNDER;
// The maximum gas price a transaction sent to this adapter may have. This is set to prevent a block producer from setting an artificially high priority fee
// when calling a hub pool message relay, which would otherwise cause a large amount of the custom gas token to be sent to L2.
uint256 private immutable MAX_TX_GASPRICE;
event ZkStackMessageRelayed(bytes32 indexed canonicalTxHash);
error ETHGasTokenNotAllowed();
error TransactionFeeTooHigh();
/**
* @notice Constructs new Adapter.
* @param _chainId The target ZkStack network's chain ID.
* @param _bridgeHub The bridge hub contract address for the ZkStack network.
* @param _l1Weth WETH address on L1.
* @param _l2RefundAddress address that recieves excess gas refunds on L2.
* @param _customGasTokenFunder Contract on L1 which funds bridge fees with amounts in the custom gas token.
* @param _l2GasLimit The maximum amount of gas this contract is willing to pay to execute a transaction on L2.
* @param _l1GasToL2GasPerPubDataLimit The exchange rate of l1 gas to l2 gas.
* @param _maxTxGasprice The maximum effective gas price any transaction sent to this adapter may have.
*/
constructor(
uint256 _chainId,
BridgeHubInterface _bridgeHub,
WETH9Interface _l1Weth,
address _l2RefundAddress,
FunderInterface _customGasTokenFunder,
uint256 _l2GasLimit,
uint256 _l1GasToL2GasPerPubDataLimit,
uint256 _maxTxGasprice
) {
CHAIN_ID = _chainId;
BRIDGE_HUB = _bridgeHub;
L1_WETH = _l1Weth;
L2_REFUND_ADDRESS = _l2RefundAddress;
CUSTOM_GAS_TOKEN_FUNDER = _customGasTokenFunder;
L2_GAS_LIMIT = _l2GasLimit;
MAX_TX_GASPRICE = _maxTxGasprice;
L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT = _l1GasToL2GasPerPubDataLimit;
SHARED_BRIDGE = BRIDGE_HUB.sharedBridge();
CUSTOM_GAS_TOKEN = BRIDGE_HUB.baseToken(CHAIN_ID);
if (CUSTOM_GAS_TOKEN == ETH_TOKEN_ADDRESS) {
revert ETHGasTokenNotAllowed();
}
}
/**
* @notice Send cross-chain message to target on ZkStack.
* @dev The CUSTOM_GAS_TOKEN_FUNDER must hold enough of the gas token to pay for the L2 txn.
* @param target Contract on L2 that will receive message.
* @param message Data to send to target.
*/
function relayMessage(address target, bytes memory message) external payable override {
uint256 txBaseCost = _pullCustomGas(L2_GAS_LIMIT);
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);
// Returns the hash of the requested L2 transaction. This hash can be used to follow the transaction status.
bytes32 canonicalTxHash = BRIDGE_HUB.requestL2TransactionDirect(
BridgeHubInterface.L2TransactionRequestDirect({
chainId: CHAIN_ID,
mintValue: txBaseCost,
l2Contract: target,
l2Value: 0,
l2Calldata: message,
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
factoryDeps: new bytes[](0),
refundRecipient: L2_REFUND_ADDRESS
})
);
emit MessageRelayed(target, message);
emit ZkStackMessageRelayed(canonicalTxHash);
}
/**
* @notice Bridge tokens to ZkStack.
* @dev The CUSTOM_GAS_TOKEN_FUNDER must hold enough of the gas token to pay for the L2 txn.
* @param l1Token L1 token to deposit.
* @param l2Token L2 token to receive.
* @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
* @param to Bridge recipient.
*/
function relayTokens(
address l1Token,
address l2Token, // l2Token is unused.
uint256 amount,
address to
) external payable override {
// A bypass proxy seems to no longer be needed to avoid deposit limits. The tracking of these limits seems to be deprecated.
// See: https://github.com/matter-labs/era-contracts/blob/bce4b2d0f34bd87f1aaadd291772935afb1c3bd6/l1-contracts/contracts/bridge/L1ERC20Bridge.sol#L54-L55
uint256 txBaseCost = _pullCustomGas(L2_GAS_LIMIT);
bytes32 txHash;
if (l1Token == address(L1_WETH)) {
// If the l1Token is WETH then unwrap it to ETH then send the ETH to the standard bridge along with the base
// cost of custom gas tokens.
L1_WETH.withdraw(amount);
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);
// Note: When bridging ETH with `L2TransactionRequestTwoBridgesOuter`, the second bridge must be 0 for the shared bridge call to not revert.
// https://github.com/matter-labs/era-contracts/blob/aafee035db892689df3f7afe4b89fd6467a39313/l1-contracts/contracts/bridge/L1SharedBridge.sol#L328
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges{ value: amount }(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
mintValue: txBaseCost,
l2Value: 0,
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
refundRecipient: L2_REFUND_ADDRESS,
secondBridgeAddress: SHARED_BRIDGE,
secondBridgeValue: amount,
secondBridgeCalldata: _secondBridgeCalldata(to, ETH_TOKEN_ADDRESS, 0)
})
);
} else if (l1Token == CUSTOM_GAS_TOKEN) {
// The chain's custom gas token.
IERC20(l1Token).forceApprove(SHARED_BRIDGE, txBaseCost + amount);
txHash = BRIDGE_HUB.requestL2TransactionDirect(
BridgeHubInterface.L2TransactionRequestDirect({
chainId: CHAIN_ID,
mintValue: txBaseCost + amount,
l2Contract: to,
l2Value: amount,
l2Calldata: "",
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
factoryDeps: new bytes[](0),
refundRecipient: L2_REFUND_ADDRESS
})
);
} else {
// An ERC20 that is not WETH and not the custom gas token.
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);
IERC20(l1Token).forceApprove(SHARED_BRIDGE, amount);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
mintValue: txBaseCost,
l2Value: 0,
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
refundRecipient: L2_REFUND_ADDRESS,
secondBridgeAddress: SHARED_BRIDGE,
secondBridgeValue: 0,
secondBridgeCalldata: _secondBridgeCalldata(to, l1Token, amount)
})
);
}
emit TokensRelayed(l1Token, l2Token, amount, to);
emit ZkStackMessageRelayed(txHash);
}
/**
* @notice Computes the calldata for the "second bridge", which handles sending non native tokens.
* @param l2Recipient recipient of the tokens.
* @param l1Token the l1 address of the token. Note: ETH is encoded as address(1).
* @param amount number of tokens to send.
* @return abi encoded bytes.
*/
function _secondBridgeCalldata(
address l2Recipient,
address l1Token,
uint256 amount
) internal pure returns (bytes memory) {
return abi.encode(l1Token, amount, l2Recipient);
}
/**
* @notice For a given l2 gas limit, this computes the amount of tokens needed, pulls them from the funder, and
* returns the amount.
* @dev Should return a value in the same precision as the gas token's precision.
* @param l2GasLimit L2 gas limit for the message.
* @return amount of gas token that this contract needs to provide in order for the l2 transaction to succeed.
*/
function _pullCustomGas(uint256 l2GasLimit) internal returns (uint256) {
if (tx.gasprice > MAX_TX_GASPRICE) revert TransactionFeeTooHigh();
uint256 cost = BRIDGE_HUB.l2TransactionBaseCost(
CHAIN_ID,
tx.gasprice,
l2GasLimit,
L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT
);
CUSTOM_GAS_TOKEN_FUNDER.withdraw(IERC20(CUSTOM_GAS_TOKEN), cost);
return cost;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// 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 Address {
/**
* @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: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @notice Sends cross chain messages and tokens to contracts on a specific L2 network.
* This interface is implemented by an adapter contract that is deployed on L1.
*/
interface AdapterInterface {
event MessageRelayed(address target, bytes message);
event TokensRelayed(address l1Token, address l2Token, uint256 amount, address to);
/**
* @notice Send message to `target` on L2.
* @dev This method is marked payable because relaying the message might require a fee
* to be paid by the sender to forward the message to L2. However, it will not send msg.value
* to the target contract on L2.
* @param target L2 address to send message to.
* @param message Message to send to `target`.
*/
function relayMessage(address target, bytes calldata message) external payable;
/**
* @notice Send `amount` of `l1Token` to `to` on L2. `l2Token` is the L2 address equivalent of `l1Token`.
* @dev This method is marked payable because relaying the message might require a fee
* to be paid by the sender to forward the message to L2. However, it will not send msg.value
* to the target contract on L2.
* @param l1Token L1 token to bridge.
* @param l2Token L2 token to receive.
* @param amount Amount of `l1Token` to bridge.
* @param to Bridge recipient.
*/
function relayTokens(
address l1Token,
address l2Token,
uint256 amount,
address to
) external payable;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @notice Interface for the WETH9 contract.
*/
interface WETH9Interface {
/**
* @notice Burn Wrapped Ether and receive native Ether.
* @param wad Amount of WETH to unwrap and send to caller.
*/
function withdraw(uint256 wad) external;
/**
* @notice Lock native Ether and mint Wrapped Ether ERC20
* @dev msg.value is amount of Wrapped Ether to mint/Ether to lock.
*/
function deposit() external payable;
/**
* @notice Get balance of WETH held by `guy`.
* @param guy Address to get balance of.
* @return wad Amount of WETH held by `guy`.
*/
function balanceOf(address guy) external view returns (uint256 wad);
/**
* @notice Transfer `wad` of WETH from caller to `guy`.
* @param guy Address to send WETH to.
* @param wad Amount of WETH to send.
* @return ok True if transfer succeeded.
*/
function transfer(address guy, uint256 wad) external returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title BridgeHubInterface
* @notice This interface is shared between ZkStack adapters. It is the main interaction point for bridging to ZkStack chains.
*/
interface BridgeHubInterface {
struct L2TransactionRequestDirect {
uint256 chainId;
uint256 mintValue;
address l2Contract;
uint256 l2Value;
bytes l2Calldata;
uint256 l2GasLimit;
uint256 l2GasPerPubdataByteLimit;
bytes[] factoryDeps;
address refundRecipient;
}
/**
* @notice the mailbox is called directly after the sharedBridge received the deposit.
* This assumes that either ether is the base token or the msg.sender has approved mintValue allowance for the
* sharedBridge. This means this is not ideal for contract calls, as the contract would have to handle token
* allowance of the base Token.
* @param _request the direct request.
*/
function requestL2TransactionDirect(L2TransactionRequestDirect calldata _request)
external
payable
returns (bytes32 canonicalTxHash);
struct L2TransactionRequestTwoBridgesOuter {
uint256 chainId;
uint256 mintValue;
uint256 l2Value;
uint256 l2GasLimit;
uint256 l2GasPerPubdataByteLimit;
address refundRecipient;
address secondBridgeAddress;
uint256 secondBridgeValue;
bytes secondBridgeCalldata;
}
/**
* @notice After depositing funds to the sharedBridge, the secondBridge is called to return the actual L2 message
* which is sent to the Mailbox. This assumes that either ether is the base token or the msg.sender has approved
* the sharedBridge with the mintValue, and also the necessary approvals are given for the second bridge. The logic
* of this bridge is to allow easy depositing for bridges. Each contract that handles the users ERC20 tokens needs
* approvals from the user, this contract allows the user to approve for each token only its respective bridge.
* This function is great for contract calls to L2, the secondBridge can be any contract.
* @param _request the two bridges request.
*/
function requestL2TransactionTwoBridges(L2TransactionRequestTwoBridgesOuter calldata _request)
external
payable
returns (bytes32 canonicalTxHash);
/**
* @notice Gets the shared bridge.
* @dev The shared bridge manages ERC20 tokens.
*/
function sharedBridge() external view returns (address);
/**
* @notice Gets the base token for a chain.
* @dev Base token == native token.
*/
function baseToken(uint256 _chainId) external view returns (address);
/**
* @notice Computes the base transaction cost for a transaction.
* @param _chainId the chain the transaction is being sent to.
* @param _gasPrice the l1 gas price at time of execution.
* @param _l2GasLimit the gas limit for the l2 transaction.
* @param _l2GasPerPubdataByteLimit configuration value that changes infrequently.
*/
function l2TransactionBaseCost(
uint256 _chainId,
uint256 _gasPrice,
uint256 _l2GasLimit,
uint256 _l2GasPerPubdataByteLimit
) external view returns (uint256);
}{
"optimizer": {
"enabled": true,
"runs": 1000000
},
"viaIR": true,
"debug": {
"revertStrings": "strip"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"uint256","name":"_chainId","type":"uint256"},{"internalType":"contract BridgeHubInterface","name":"_bridgeHub","type":"address"},{"internalType":"contract WETH9Interface","name":"_l1Weth","type":"address"},{"internalType":"address","name":"_l2RefundAddress","type":"address"},{"internalType":"contract FunderInterface","name":"_customGasTokenFunder","type":"address"},{"internalType":"uint256","name":"_l2GasLimit","type":"uint256"},{"internalType":"uint256","name":"_l1GasToL2GasPerPubDataLimit","type":"uint256"},{"internalType":"uint256","name":"_maxTxGasprice","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ETHGasTokenNotAllowed","type":"error"},{"inputs":[],"name":"TransactionFeeTooHigh","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"MessageRelayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"l1Token","type":"address"},{"indexed":false,"internalType":"address","name":"l2Token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"TokensRelayed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"canonicalTxHash","type":"bytes32"}],"name":"ZkStackMessageRelayed","type":"event"},{"inputs":[],"name":"BRIDGE_HUB","outputs":[{"internalType":"contract BridgeHubInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CHAIN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CUSTOM_GAS_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CUSTOM_GAS_TOKEN_FUNDER","outputs":[{"internalType":"contract FunderInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L1_WETH","outputs":[{"internalType":"contract WETH9Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_GAS_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_REFUND_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SHARED_BRIDGE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"relayMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"l1Token","type":"address"},{"internalType":"address","name":"l2Token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"relayTokens","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
6101c0604081815234620002a4578162001991803803809162000023828562000303565b833961010093849181010312620002a45780516020808301516001600160a01b038082169593949390868303620002a45781850151968188168803620002a45762000071606087016200033b565b906080870151968388168803620002a457600495879360a08301519160e060c08501519401519b60e0528d526101209b8c5260c0526101809889526080526101a098895260a05283519485809263070e40ef60e31b82525afa928315620002f9575f93620002ba575b50610140928352808851168460e0516024855180948193632cf632d160e11b835260048301525afa948515620002b0575f956200026a575b505061016084815293166001146200025a575194611640968762000351883960805187818161012b015281816104d801526106b4015260a0518781816102150152818161047f0152818161081101528181610a8b01528181610c7d015261127c015260c0518781816102410152818161083801528181610ab701528181610ca40152610e69015260e0518781816101d601528181610426015281816107e201528181610a4101528181610c4e015261124b01525186818161029e01528181610546015281816108a601528181610b1401528181610d1201526112a90152518581816106e40152610dfd0152518481816101710152818161062401528181610762015281816109f90152610bea015251838181610193015281816105b501528181610789015281816109b101526113380152518281816103c801526112dd015251816111e80152f35b5163958e6ea160e01b8152600490fd5b9080929550813d8311620002a8575b62000285818362000303565b81010312620002a4576200029b6001916200033b565b93905f62000112565b5f80fd5b503d62000279565b83513d5f823e3d90fd5b9092508381813d8311620002f1575b620002d5818362000303565b81010312620002a457620002e9906200033b565b915f620000da565b503d620002c9565b82513d5f823e3d90fd5b601f909101601f19168101906001600160401b038211908210176200032757604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b0382168203620002a45756fe60806040818152600480361015610014575f80fd5b5f925f3560e01c90816303c0501914610e21575080631efd482a14610db357806352c8c75c14610648578063546b6d2a146105d957806358f76b651461056a5780635d4edca7146104fb5780635e743ef7146104a25780636c9075b71461044957806385e1f4d0146103f0578063e58921a21461037d5763e6eb8ade14610099575f80fd5b817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610379576100ca610e8d565b906024359167ffffffffffffffff8311610375573660238401121561037557828201356100f681610f87565b9061010386519283610f46565b8082526020938736602484890101116103725785838194602461029a9a0183880137850101527f000000000000000000000000000000000000000000000000000000000000000093610154856111e6565b9173ffffffffffffffffffffffffffffffffffffffff916101b8847f0000000000000000000000000000000000000000000000000000000000000000857f0000000000000000000000000000000000000000000000000000000000000000166113e5565b828a51916101c583610f2a565b5f83528b51956101d487610eb0565b7f00000000000000000000000000000000000000000000000000000000000000008752878701521696878b8601528b606086015286608086015260a08501527f000000000000000000000000000000000000000000000000000000000000000060c085015260e0840152817f0000000000000000000000000000000000000000000000000000000000000000166101008401528989518099819582947fd52471c100000000000000000000000000000000000000000000000000000000845283016110e0565b03927f0000000000000000000000000000000000000000000000000000000000000000165af1938415610368578694610333575b506103099085807f9e6c52944e331ba6270e7fe4cea2a4086bae8f7a27e1cdba07f416806f5d0ac49697519586958652850152830190610fc1565b0390a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b9093508281813d8311610361575b61034b8183610f46565b8101031261035d5751926103096102ce565b5f80fd5b503d610341565b85513d88823e3d90fd5b80fd5b8480fd5b8280fd5b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5080fd5b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000000000008152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b509060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d5761067c610e8d565b6024359273ffffffffffffffffffffffffffffffffffffffff9081851680950361035d57604435906064359280841680940361035d577f0000000000000000000000000000000000000000000000000000000000000000916106dd836111e6565b95821695927f00000000000000000000000000000000000000000000000000000000000000008316858882036109a75750803b1561035d575f809160248b51809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528b898401525af1801561099d5761097d575b50928288928b956108a2957f00000000000000000000000000000000000000000000000000000000000000006107ae8682847f0000000000000000000000000000000000000000000000000000000000000000166113e5565b8651926020998a9860018a8701525f818701528d6060870152606086526107d486610f0e565b8051986107e08a610eb0565b7f00000000000000000000000000000000000000000000000000000000000000008a528a8a015288015260608701527f00000000000000000000000000000000000000000000000000000000000000006080870152817f00000000000000000000000000000000000000000000000000000000000000001660a08701521660c08501528760e0850152610100840152868a518096819582947f24fd57fb000000000000000000000000000000000000000000000000000000008452830161101d565b03927f0000000000000000000000000000000000000000000000000000000000000000165af191821561097357889261093c575b5050907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392965b815194855260208501528301526060820152a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b90809594939250813d831161096c575b6109568183610f46565b8101031261035d579251919290918460806108d6565b503d61094c565b86513d8a823e3d90fd5b919950926108a292889261099090610efa565b5f9a925092939093610755565b89513d5f823e3d90fd5b91939490508888867f0000000000000000000000000000000000000000000000000000000000000000168082145f14610bd75750505091610a238284610a1e6109f7610b109996602099986110a6565b7f00000000000000000000000000000000000000000000000000000000000000008d6113e5565b6110a6565b92895190610a3082610f2a565b5f82528a5194610a3f86610eb0565b7f0000000000000000000000000000000000000000000000000000000000000000865286860152888b8601528760608601528a51610a7c81610f2a565b5f8152608086015260a08501527f000000000000000000000000000000000000000000000000000000000000000060c085015260e0840152817f0000000000000000000000000000000000000000000000000000000000000000166101008401525f89518096819582947fd52471c100000000000000000000000000000000000000000000000000000000845283016110e0565b03927f0000000000000000000000000000000000000000000000000000000000000000165af1908115610bcd575f91610b73575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b94608094939296610902565b93929190506020843d602011610bc5575b81610b9160209383610f46565b8101031261035d579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b610b44565b3d9150610b84565b85513d5f823e3d90fd5b83945096610d0e9691959297610c1082957f000000000000000000000000000000000000000000000000000000000000000080936113e5565b610c1b8a82896113e5565b8851925f60209a8b998a8701528c818701528d606087015260608652610c4086610f0e565b805198610c4c8a610eb0565b7f00000000000000000000000000000000000000000000000000000000000000008a528a8a015288015260608701527f00000000000000000000000000000000000000000000000000000000000000006080870152817f00000000000000000000000000000000000000000000000000000000000000001660a08701521660c08501525f60e08501526101008401525f8a518096819582947f24fd57fb000000000000000000000000000000000000000000000000000000008452830161101d565b03927f0000000000000000000000000000000000000000000000000000000000000000165af1918215610da9575f92610d72575b5050907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b94608094939296610902565b90809594939250813d8311610da2575b610d8c8183610f46565b8101031261035d57925191929091846080610d42565b503d610d82565b86513d5f823e3d90fd5b823461035d575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461035d575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d5760209073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361035d57565b610120810190811067ffffffffffffffff821117610ecd57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111610ecd57604052565b6080810190811067ffffffffffffffff821117610ecd57604052565b6020810190811067ffffffffffffffff821117610ecd57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610ecd57604052565b67ffffffffffffffff8111610ecd57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b91908251928382525f5b8481106110095750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b602081830181015184830182015201610fcb565b6101406110a3926020835280516020840152602081015160408401526040810151606084015260608101516080840152608081015160a084015260a081015173ffffffffffffffffffffffffffffffffffffffff80911660c085015260c08201511660e084015260e0810151906101009182850152015191610120808201520190610fc1565b90565b919082018092116110b357565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6020808252825181830152808301516040830152604083015173ffffffffffffffffffffffffffffffffffffffff80911660608401526060840151608084015260808401519161113e610120938460a0870152610140860190610fc1565b9460a081015160c086015260c081015160e086015260e0810151957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0906101009382888303018589015288519182815281810182808560051b8401019b01945f925b8584106111b7575050505050505001511691015290565b9091929394959b85806111d58f936001948787830301895251610fc1565b9e01940194019295949391906111a0565b7f00000000000000000000000000000000000000000000000000000000000000003a116113bb5773ffffffffffffffffffffffffffffffffffffffff604051917f716232740000000000000000000000000000000000000000000000000000000083527f000000000000000000000000000000000000000000000000000000000000000060048401523a602484015260448301527f00000000000000000000000000000000000000000000000000000000000000006064830152602082608481847f0000000000000000000000000000000000000000000000000000000000000000165afa91821561137c575f92611387575b50807f00000000000000000000000000000000000000000000000000000000000000001690813b1561035d575f916044839260405194859384927ff3fef3a30000000000000000000000000000000000000000000000000000000084527f00000000000000000000000000000000000000000000000000000000000000001660048401528760248401525af1801561137c57611373575090565b6110a390610efa565b6040513d5f823e3d90fd5b9091506020813d6020116113b3575b816113a360209383610f46565b8101031261035d5751905f6112d9565b3d9150611396565b60046040517fb33009b4000000000000000000000000000000000000000000000000000000008152fd5b91909160405191602083015f807f095ea7b3000000000000000000000000000000000000000000000000000000009687845273ffffffffffffffffffffffffffffffffffffffff8091169485602489015260448801526044875261144887610f0e565b85169286519082855af19061145b6114ef565b826114bd575b50816114b2575b5015611475575b50505050565b6114a9936114a49160405191602083015260248201525f60448201526044815261149e81610f0e565b82611536565b611536565b5f80808061146f565b90503b15155f611468565b805191925081159182156114d5575b5050905f611461565b6114e8925060208091830101910161151e565b5f806114cc565b3d15611519573d9061150082610f87565b9161150e6040519384610f46565b82523d5f602084013e565b606090565b9081602091031261035d5751801515810361035d5790565b73ffffffffffffffffffffffffffffffffffffffff166040516040810181811067ffffffffffffffff821117610ecd576115b1937f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460205f948594604052818152015260208151910182855af16115ab6114ef565b916115e1565b80519081159182156115c7575b50501561035d57565b6115da925060208091830101910161151e565b5f806115be565b90156115fb578151156115f2575090565b3b1561035d5790565b50805190811561035d57602001fdfea264697066735822122083b06967ec48b38cb0c247396a70f7c7726c52a2dbb91f96a1a0aedd3817770e64736f6c6343000817003300000000000000000000000000000000000000000000000000000000000090f7000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b1400000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e6700000000000000000000000074f00724075443cbbf55129f17cbab0f77ba072200000000000000000000000000000000000000000000000000000000001e84800000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000009184e72a000
Deployed Bytecode
0x60806040818152600480361015610014575f80fd5b5f925f3560e01c90816303c0501914610e21575080631efd482a14610db357806352c8c75c14610648578063546b6d2a146105d957806358f76b651461056a5780635d4edca7146104fb5780635e743ef7146104a25780636c9075b71461044957806385e1f4d0146103f0578063e58921a21461037d5763e6eb8ade14610099575f80fd5b817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610379576100ca610e8d565b906024359167ffffffffffffffff8311610375573660238401121561037557828201356100f681610f87565b9061010386519283610f46565b8082526020938736602484890101116103725785838194602461029a9a0183880137850101527f00000000000000000000000000000000000000000000000000000000001e848093610154856111e6565b9173ffffffffffffffffffffffffffffffffffffffff916101b8847f0000000000000000000000006f03861d12e6401623854e494beacd66bc46e6f0857f0000000000000000000000002be68b15c693d3b5747f9f0d49d30a2e81baa2df166113e5565b828a51916101c583610f2a565b5f83528b51956101d487610eb0565b7f00000000000000000000000000000000000000000000000000000000000090f78752878701521696878b8601528b606086015286608086015260a08501527f000000000000000000000000000000000000000000000000000000000000032060c085015260e0840152817f00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67166101008401528989518099819582947fd52471c100000000000000000000000000000000000000000000000000000000845283016110e0565b03927f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce165af1938415610368578694610333575b506103099085807f9e6c52944e331ba6270e7fe4cea2a4086bae8f7a27e1cdba07f416806f5d0ac49697519586958652850152830190610fc1565b0390a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b9093508281813d8311610361575b61034b8183610f46565b8101031261035d5751926103096102ce565b5f80fd5b503d610341565b85513d88823e3d90fd5b80fd5b8480fd5b8280fd5b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000074f00724075443cbbf55129f17cbab0f77ba0722168152f35b5080fd5b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000000090f78152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000000003208152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec57602090517f00000000000000000000000000000000000000000000000000000000001e84808152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce168152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000002be68b15c693d3b5747f9f0d49d30a2e81baa2df168152f35b5050346103ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103ec576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f03861d12e6401623854e494beacd66bc46e6f0168152f35b509060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d5761067c610e8d565b6024359273ffffffffffffffffffffffffffffffffffffffff9081851680950361035d57604435906064359280841680940361035d577f00000000000000000000000000000000000000000000000000000000001e8480916106dd836111e6565b95821695927f000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b148316858882036109a75750803b1561035d575f809160248b51809481937f2e1a7d4d0000000000000000000000000000000000000000000000000000000083528b898401525af1801561099d5761097d575b50928288928b956108a2957f0000000000000000000000006f03861d12e6401623854e494beacd66bc46e6f06107ae8682847f0000000000000000000000002be68b15c693d3b5747f9f0d49d30a2e81baa2df166113e5565b8651926020998a9860018a8701525f818701528d6060870152606086526107d486610f0e565b8051986107e08a610eb0565b7f00000000000000000000000000000000000000000000000000000000000090f78a528a8a015288015260608701527f00000000000000000000000000000000000000000000000000000000000003206080870152817f00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e671660a08701521660c08501528760e0850152610100840152868a518096819582947f24fd57fb000000000000000000000000000000000000000000000000000000008452830161101d565b03927f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce165af191821561097357889261093c575b5050907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b946080949392965b815194855260208501528301526060820152a17fb50bccea676fbc831e47d257acd0dbaa101ff4d469933d6d9e6ad85c2d4b63b98280a280f35b90809594939250813d831161096c575b6109568183610f46565b8101031261035d579251919290918460806108d6565b503d61094c565b86513d8a823e3d90fd5b919950926108a292889261099090610efa565b5f9a925092939093610755565b89513d5f823e3d90fd5b91939490508888867f0000000000000000000000002be68b15c693d3b5747f9f0d49d30a2e81baa2df168082145f14610bd75750505091610a238284610a1e6109f7610b109996602099986110a6565b7f0000000000000000000000006f03861d12e6401623854e494beacd66bc46e6f08d6113e5565b6110a6565b92895190610a3082610f2a565b5f82528a5194610a3f86610eb0565b7f00000000000000000000000000000000000000000000000000000000000090f7865286860152888b8601528760608601528a51610a7c81610f2a565b5f8152608086015260a08501527f000000000000000000000000000000000000000000000000000000000000032060c085015260e0840152817f00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67166101008401525f89518096819582947fd52471c100000000000000000000000000000000000000000000000000000000845283016110e0565b03927f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce165af1908115610bcd575f91610b73575b50907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b94608094939296610902565b93929190506020843d602011610bc5575b81610b9160209383610f46565b8101031261035d579251919290917fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b610b44565b3d9150610b84565b85513d5f823e3d90fd5b83945096610d0e9691959297610c1082957f0000000000000000000000006f03861d12e6401623854e494beacd66bc46e6f080936113e5565b610c1b8a82896113e5565b8851925f60209a8b998a8701528c818701528d606087015260608652610c4086610f0e565b805198610c4c8a610eb0565b7f00000000000000000000000000000000000000000000000000000000000090f78a528a8a015288015260608701527f00000000000000000000000000000000000000000000000000000000000003206080870152817f00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e671660a08701521660c08501525f60e08501526101008401525f8a518096819582947f24fd57fb000000000000000000000000000000000000000000000000000000008452830161101d565b03927f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce165af1918215610da9575f92610d72575b5050907fd7e09655439c3932e55857df3220186e5a7f0980825f20691c2b35d941dee75b94608094939296610902565b90809594939250813d8311610da2575b610d8c8183610f46565b8101031261035d57925191929091846080610d42565b503d610d82565b86513d5f823e3d90fd5b823461035d575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b14168152f35b3461035d575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261035d5760209073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67168152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361035d57565b610120810190811067ffffffffffffffff821117610ecd57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff8111610ecd57604052565b6080810190811067ffffffffffffffff821117610ecd57604052565b6020810190811067ffffffffffffffff821117610ecd57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610ecd57604052565b67ffffffffffffffff8111610ecd57601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b91908251928382525f5b8481106110095750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b602081830181015184830182015201610fcb565b6101406110a3926020835280516020840152602081015160408401526040810151606084015260608101516080840152608081015160a084015260a081015173ffffffffffffffffffffffffffffffffffffffff80911660c085015260c08201511660e084015260e0810151906101009182850152015191610120808201520190610fc1565b90565b919082018092116110b357565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6020808252825181830152808301516040830152604083015173ffffffffffffffffffffffffffffffffffffffff80911660608401526060840151608084015260808401519161113e610120938460a0870152610140860190610fc1565b9460a081015160c086015260c081015160e086015260e0810151957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0906101009382888303018589015288519182815281810182808560051b8401019b01945f925b8584106111b7575050505050505001511691015290565b9091929394959b85806111d58f936001948787830301895251610fc1565b9e01940194019295949391906111a0565b7f000000000000000000000000000000000000000000000000000009184e72a0003a116113bb5773ffffffffffffffffffffffffffffffffffffffff604051917f716232740000000000000000000000000000000000000000000000000000000083527f00000000000000000000000000000000000000000000000000000000000090f760048401523a602484015260448301527f00000000000000000000000000000000000000000000000000000000000003206064830152602082608481847f000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce165afa91821561137c575f92611387575b50807f00000000000000000000000074f00724075443cbbf55129f17cbab0f77ba07221690813b1561035d575f916044839260405194859384927ff3fef3a30000000000000000000000000000000000000000000000000000000084527f0000000000000000000000002be68b15c693d3b5747f9f0d49d30a2e81baa2df1660048401528760248401525af1801561137c57611373575090565b6110a390610efa565b6040513d5f823e3d90fd5b9091506020813d6020116113b3575b816113a360209383610f46565b8101031261035d5751905f6112d9565b3d9150611396565b60046040517fb33009b4000000000000000000000000000000000000000000000000000000008152fd5b91909160405191602083015f807f095ea7b3000000000000000000000000000000000000000000000000000000009687845273ffffffffffffffffffffffffffffffffffffffff8091169485602489015260448801526044875261144887610f0e565b85169286519082855af19061145b6114ef565b826114bd575b50816114b2575b5015611475575b50505050565b6114a9936114a49160405191602083015260248201525f60448201526044815261149e81610f0e565b82611536565b611536565b5f80808061146f565b90503b15155f611468565b805191925081159182156114d5575b5050905f611461565b6114e8925060208091830101910161151e565b5f806114cc565b3d15611519573d9061150082610f87565b9161150e6040519384610f46565b82523d5f602084013e565b606090565b9081602091031261035d5751801515810361035d5790565b73ffffffffffffffffffffffffffffffffffffffff166040516040810181811067ffffffffffffffff821117610ecd576115b1937f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460205f948594604052818152015260208151910182855af16115ab6114ef565b916115e1565b80519081159182156115c7575b50501561035d57565b6115da925060208091830101910161151e565b5f806115be565b90156115fb578151156115f2575090565b3b1561035d5790565b50805190811561035d57602001fdfea264697066735822122083b06967ec48b38cb0c247396a70f7c7726c52a2dbb91f96a1a0aedd3817770e64736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000090f7000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b1400000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e6700000000000000000000000074f00724075443cbbf55129f17cbab0f77ba072200000000000000000000000000000000000000000000000000000000001e84800000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000009184e72a000
-----Decoded View---------------
Arg [0] : _chainId (uint256): 37111
Arg [1] : _bridgeHub (address): 0x236D1c3Ff32Bd0Ca26b72Af287E895627c0478cE
Arg [2] : _l1Weth (address): 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
Arg [3] : _l2RefundAddress (address): 0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67
Arg [4] : _customGasTokenFunder (address): 0x74f00724075443Cbbf55129F17CbAB0F77bA0722
Arg [5] : _l2GasLimit (uint256): 2000000
Arg [6] : _l1GasToL2GasPerPubDataLimit (uint256): 800
Arg [7] : _maxTxGasprice (uint256): 10000000000000
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000090f7
Arg [1] : 000000000000000000000000236d1c3ff32bd0ca26b72af287e895627c0478ce
Arg [2] : 000000000000000000000000fff9976782d46cc05630d1f6ebab18b2324d6b14
Arg [3] : 00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67
Arg [4] : 00000000000000000000000074f00724075443cbbf55129f17cbab0f77ba0722
Arg [5] : 00000000000000000000000000000000000000000000000000000000001e8480
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [7] : 000000000000000000000000000000000000000000000000000009184e72a000
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.