L2GatewayRouter
L2GatewayRouter
The L2GatewayRouter is the main entry for withdrawing Ether and ERC20 tokens. All deposited tokens are routed to corresponding gateways.
One can also use this contract to query L1/L2 token address mapping. In the future, ERC-721 and ERC-1155 tokens will be added to the router too.
Methods
ERC20Gateway
Mapping from L2 ERC20 token address to corresponding L2ERC20Gateway.
Parameters
| Name |
Type |
Description |
| _0 |
address |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
counterpart
The address of corresponding L1/L2 Gateway contract.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
defaultERC20Gateway
The addess of default L2 ERC20 gateway, normally the L2StandardERC20Gateway contract.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
finalizeDepositERC20
Complete a deposit from L1 to L2 and send fund to recipient's account in L2.
Make this function payable to handle WETH deposit/withdraw. The function should only be called by L2ScrollMessenger. The function should also only be called by L1ERC20Gateway in L1.
Parameters
| Name |
Type |
Description |
| _0 |
address |
undefined |
| _1 |
address |
undefined |
| _2 |
address |
undefined |
| _3 |
address |
undefined |
| _4 |
uint256 |
undefined |
| _5 |
bytes |
undefined |
finalizeDepositETH
Complete ETH deposit from L1 to L2 and send fund to recipient's account in L2.
This function should only be called by L2ScrollMessenger. This function should also only be called by L1GatewayRouter in L1.
Parameters
| Name |
Type |
Description |
| _from |
address |
The address of account who deposit ETH in L1. |
| _to |
address |
The address of recipient in L2 to receive ETH. |
| _amount |
uint256 |
The amount of ETH to deposit. |
| _data |
bytes |
Optional data to forward to recipient's account. |
finalizeDropMessage
getERC20Gateway
Return the corresponding gateway address for given token address.
Parameters
| Name |
Type |
Description |
| _token |
address |
The address of token to query. |
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
getL1ERC20Address
Return the corresponding l1 token address given l2 token address.
Parameters
| Name |
Type |
Description |
| _l2Address |
address |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
getL2ERC20Address
Return the corresponding l2 token address given l1 token address.
Parameters
| Name |
Type |
Description |
| _0 |
address |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
initialize
Parameters
| Name |
Type |
Description |
| _defaultERC20Gateway |
address |
undefined |
| _counterpart |
address |
undefined |
| _messenger |
address |
undefined |
messenger
The address of L1ScrollMessenger/L2ScrollMessenger contract.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
owner
Returns the address of the current owner.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
renounceOwnership
Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
router
The address of L1GatewayRouter/L2GatewayRouter contract.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
setDefaultERC20Gateway
Update the address of default ERC20 gateway contract.
This function should only be called by contract owner.
Parameters
| Name |
Type |
Description |
| _defaultERC20Gateway |
address |
The address to update. |
setERC20Gateway
Update the mapping from token address to gateway address.
This function should only be called by contract owner.
Parameters
| Name |
Type |
Description |
| _tokens |
address[] |
The list of addresses of tokens to update. |
| _gateways |
address[] |
The list of addresses of gateways to update. |
transferOwnership
Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.
Parameters
| Name |
Type |
Description |
| newOwner |
address |
undefined |
withdrawERC20
Withdraw of some token to a caller's account on L1.
Make this function payable to send relayer fee in Ether.
Parameters
| Name |
Type |
Description |
| _token |
address |
The address of token in L2. |
| _amount |
uint256 |
The amount of token to transfer. |
| _gasLimit |
uint256 |
Unused, but included for potential forward compatibility considerations. |
withdrawERC20
Withdraw of some token to a recipient's account on L1.
Make this function payable to send relayer fee in Ether.
Parameters
| Name |
Type |
Description |
| _token |
address |
The address of token in L2. |
| _to |
address |
The address of recipient's account on L1. |
| _amount |
uint256 |
The amount of token to transfer. |
| _gasLimit |
uint256 |
Unused, but included for potential forward compatibility considerations. |
withdrawERC20AndCall
Withdraw of some token to a recipient's account on L1 and call.
Make this function payable to send relayer fee in Ether.
Parameters
| Name |
Type |
Description |
| _token |
address |
The address of token in L2. |
| _to |
address |
The address of recipient's account on L1. |
| _amount |
uint256 |
The amount of token to transfer. |
| _data |
bytes |
Optional data to forward to recipient's account. |
| _gasLimit |
uint256 |
Unused, but included for potential forward compatibility considerations. |
withdrawETH
Withdraw ETH to caller's account in L1.
Parameters
| Name |
Type |
Description |
| _to |
address |
The address of recipient's account on L1. |
| _gasLimit |
uint256 |
Gas limit required to complete the withdraw on L1. |
withdrawETH
Withdraw ETH to caller's account in L1.
Parameters
| Name |
Type |
Description |
| _gasLimit |
uint256 |
Gas limit required to complete the withdraw on L1. |
Events
FinalizeDepositERC20
Parameters
| Name |
Type |
Description |
_l1Token indexed |
address |
undefined |
_l2Token indexed |
address |
undefined |
_from indexed |
address |
undefined |
| _to |
address |
undefined |
| _amount |
uint256 |
undefined |
| _data |
bytes |
undefined |
FinalizeDepositETH
Parameters
| Name |
Type |
Description |
_from indexed |
address |
undefined |
_to indexed |
address |
undefined |
| _amount |
uint256 |
undefined |
| _data |
bytes |
undefined |
OwnershipTransferred
Parameters
| Name |
Type |
Description |
previousOwner indexed |
address |
undefined |
newOwner indexed |
address |
undefined |
SetDefaultERC20Gateway
Parameters
| Name |
Type |
Description |
_defaultERC20Gateway indexed |
address |
undefined |
SetERC20Gateway
Parameters
| Name |
Type |
Description |
_token indexed |
address |
undefined |
_gateway indexed |
address |
undefined |
WithdrawERC20
Parameters
| Name |
Type |
Description |
_l1Token indexed |
address |
undefined |
_l2Token indexed |
address |
undefined |
_from indexed |
address |
undefined |
| _to |
address |
undefined |
| _amount |
uint256 |
undefined |
| _data |
bytes |
undefined |
WithdrawETH
Parameters
| Name |
Type |
Description |
_from indexed |
address |
undefined |
_to indexed |
address |
undefined |
| _amount |
uint256 |
undefined |
| _data |
bytes |
undefined |