ISettlementChainGateway
Inherits: IMigratable, IRegistryParametersErrors
A SettlementChainGateway exposes the ability to send parameters to any app chain gateways, via their respective inboxes on the settlement chain.
Functions
initialize
Initializes the contract.
function initialize() external;
deposit
Deposits fee tokens as gas token to an app chain.
function deposit(uint256 chainId_, address recipient_, uint256 amount_, uint256 gasLimit_, uint256 maxFeePerGas_)
external;
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID of the target app chain. |
recipient_ | address | The recipient of the tokens. |
amount_ | uint256 | The amount of tokens to deposit. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
depositWithPermit
Deposits fee tokens as gas token to an app chain, given caller's signed approval.
function depositWithPermit(
uint256 chainId_,
address recipient_,
uint256 amount_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 deadline_,
uint8 v_,
bytes32 r_,
bytes32 s_
) external;
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID of the target app chain. |
recipient_ | address | The recipient of the tokens. |
amount_ | uint256 | The amount of tokens to deposit. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
deadline_ | uint256 | The deadline of the permit (must be the current or future timestamp). |
v_ | uint8 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
r_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
s_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
depositFromUnderlying
Deposits fee tokens as gas token to an app chain, by wrapping underlying fee tokens.
function depositFromUnderlying(
uint256 chainId_,
address recipient_,
uint256 amount_,
uint256 gasLimit_,
uint256 maxFeePerGas_
) external;
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID of the target app chain. |
recipient_ | address | The recipient of the tokens. |
amount_ | uint256 | The amount of underlying fee tokens to deposit. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
depositFromUnderlyingWithPermit
Deposits fee tokens as gas token to an app chain, by wrapping underlying fee tokens, given caller's signed approval.
function depositFromUnderlyingWithPermit(
uint256 chainId_,
address recipient_,
uint256 amount_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 deadline_,
uint8 v_,
bytes32 r_,
bytes32 s_
) external;
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID of the target app chain. |
recipient_ | address | The recipient of the tokens. |
amount_ | uint256 | The amount of underlying fee tokens to deposit. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
deadline_ | uint256 | The deadline of the permit (must be the current or future timestamp). |
v_ | uint8 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
r_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
s_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
sendParameters
Sends parameters to the app chain as retryable tickets (which may be a direct contract call).
This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.
amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by
maxFeePerGas_, plus the submission fee for the retryable ticket.
The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by
amountToSend_ (which is returned as totalSent_).
function sendParameters(
uint256[] calldata chainIds_,
string[] calldata keys_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 amountToSend_
) external returns (uint256 totalSent_);
Parameters
| Name | Type | Description |
|---|---|---|
chainIds_ | uint256[] | The chain IDs of the target app chains. |
keys_ | string[] | The keys of the parameters. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
amountToSend_ | uint256 | The amount of fee tokens that will be pulled by each inbox. |
Returns
| Name | Type | Description |
|---|---|---|
totalSent_ | uint256 | The total amount of fee tokens sent to all app chains combined. |
sendParametersWithPermit
Sends parameters to the app chain as retryable tickets (which may be a direct contract call), given caller's signed approval to pull fee tokens.
This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.
amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by
maxFeePerGas_, plus the submission fee for the retryable ticket.
The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by
amountToSend_ (which is returned as totalSent_).
function sendParametersWithPermit(
uint256[] calldata chainIds_,
string[] calldata keys_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 amountToSend_,
uint256 deadline_,
uint8 v_,
bytes32 r_,
bytes32 s_
) external returns (uint256 totalSent_);
Parameters
| Name | Type | Description |
|---|---|---|
chainIds_ | uint256[] | The chain IDs of the target app chains. |
keys_ | string[] | The keys of the parameters. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
amountToSend_ | uint256 | The amount of fee tokens that will be pulled by each inbox. |
deadline_ | uint256 | The deadline of the permit (must be the current or future timestamp). |
v_ | uint8 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
r_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
s_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
Returns
| Name | Type | Description |
|---|---|---|
totalSent_ | uint256 | The total amount of fee tokens sent to all app chains combined. |
sendParametersFromUnderlying
Sends parameters to the app chain as retryable tickets (which may be a direct contract call).
This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.
amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by
maxFeePerGas_, plus the submission fee for the retryable ticket.
The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by
amountToSend_ (which is returned as totalSent_).
function sendParametersFromUnderlying(
uint256[] calldata chainIds_,
string[] calldata keys_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 amountToSend_
) external returns (uint256 totalSent_);
Parameters
| Name | Type | Description |
|---|---|---|
chainIds_ | uint256[] | The chain IDs of the target app chains. |
keys_ | string[] | The keys of the parameters. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
amountToSend_ | uint256 | The amount of fee tokens to send with the call to fund the alias on each app chain, which will first be converted from underlying fee tokens. |
Returns
| Name | Type | Description |
|---|---|---|
totalSent_ | uint256 | The total amount of fee tokens sent to all app chains combined. |
sendParametersFromUnderlyingWithPermit
Sends parameters to the app chain as retryable tickets (which may be a direct contract call), given caller's signed approval to pull underlying fee tokens.
This will perform an L2->L3 message, where the settlement gateway alias must have enough balance to pay for the function call (IAppChainGateway.receiveParameters), and the gas limit and price must suffice. If not, the message will remain as a retryable ticket on the app chain, that anyone can trigger and pay for.
amountToSend_ (converted to wei) must be greater or equal to the sum of gasLimit_ multiplied by
maxFeePerGas_, plus the submission fee for the retryable ticket.
The total amount of fee tokens that will be pulled from the caller is chainIds_.length multiplied by
amountToSend_ (which is returned as totalSent_).
function sendParametersFromUnderlyingWithPermit(
uint256[] calldata chainIds_,
string[] calldata keys_,
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 amountToSend_,
uint256 deadline_,
uint8 v_,
bytes32 r_,
bytes32 s_
) external returns (uint256 totalSent_);
Parameters
| Name | Type | Description |
|---|---|---|
chainIds_ | uint256[] | The chain IDs of the target app chains. |
keys_ | string[] | The keys of the parameters. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
amountToSend_ | uint256 | The amount of fee tokens to send with the call to fund the alias on each app chain, which will first be converted from underlying fee tokens. |
deadline_ | uint256 | The deadline of the permit (must be the current or future timestamp). |
v_ | uint8 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
r_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
s_ | bytes32 | An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712). |
Returns
| Name | Type | Description |
|---|---|---|
totalSent_ | uint256 | The total amount of fee tokens sent to all app chains combined. |
updateInbox
Updates the inbox for a chain ID.
function updateInbox(uint256 chainId_) external;
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID. |
receiveWithdrawal
Receives withdrawal of fee tokens from the app chain gateway.
function receiveWithdrawal(address recipient_) external returns (uint256 amount_);
Parameters
| Name | Type | Description |
|---|---|---|
recipient_ | address | The recipient of the tokens. |
Returns
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of fee tokens withdrawn. |
receiveWithdrawalIntoUnderlying
Receives withdrawal of fee tokens from the app chain gateway, and unwraps them into underlying fee tokens.
function receiveWithdrawalIntoUnderlying(address recipient_) external returns (uint256 amount_);
Parameters
| Name | Type | Description |
|---|---|---|
recipient_ | address | The recipient of the underlying fee tokens. |
Returns
| Name | Type | Description |
|---|---|---|
amount_ | uint256 | The amount of fee tokens withdrawn. |
updatePauseStatus
Updates the pause status.
Ensures the new pause status is not equal to the old pause status.
function updatePauseStatus() external;
inboxParameterKey
The parameter registry key used to fetch the inbox.
function inboxParameterKey() external pure returns (string memory key_);
migratorParameterKey
The parameter registry key used to fetch the migrator.
function migratorParameterKey() external pure returns (string memory key_);
pausedParameterKey
The parameter registry key used to fetch the paused status.
function pausedParameterKey() external pure returns (string memory key_);
parameterRegistry
The address of the parameter registry.
function parameterRegistry() external view returns (address parameterRegistry_);
appChainGateway
The address of the app chain gateway.
function appChainGateway() external view returns (address appChainGateway_);
appChainAlias
This contract's alias address on the L3 app chain.
function appChainAlias() external view returns (address appChainAlias_);
feeToken
The address of the fee token on the settlement chain, that is used to pay for gas on app chains.
function feeToken() external view returns (address feeToken_);
paused
The pause status.
function paused() external view returns (bool paused_);
calculateMaxDepositFee
Calculates the maximum fees (in wei, 18 decimals) that will be consumed for a deposit to an app chain.
function calculateMaxDepositFee(uint256 chainId_, uint256 gasLimit_, uint256 maxFeePerGas_, uint256 maxBaseFee_)
external
view
returns (uint256 fees_);
Parameters
| Name | Type | Description |
|---|---|---|
chainId_ | uint256 | The chain ID of the target app chain. |
gasLimit_ | uint256 | The gas limit for the transaction on the app chain. |
maxFeePerGas_ | uint256 | The maximum fee per gas (EIP-1559) for the transaction on the app chain. |
maxBaseFee_ | uint256 | The maximum base fee of the settlement chain, in wei (18 decimals). |
Returns
| Name | Type | Description |
|---|---|---|
fees_ | uint256 | The maximum fees (in wei, 18 decimals) that will be consumed for a deposit to an app chain. |
getInbox
The inbox address for a chain ID.
function getInbox(uint256 chainId_) external view returns (address inbox_);
Events
Deposit
Emitted when fee tokens have been sent to the app chain (becoming native gas token).
event Deposit(
uint256 indexed chainId, uint256 indexed messageNumber, address indexed recipient, uint256 amount, uint256 maxFees
);
Parameters
| Name | Type | Description |
|---|---|---|
chainId | uint256 | The chain ID of the target app chain. |
messageNumber | uint256 | The message number, unique per inbox. |
recipient | address | The recipient of the tokens on the app chain. |
amount | uint256 | The amount of tokens sent. |
maxFees | uint256 | The maximum fees that will be consumed for the deposit. |
ParametersSent
Emitted when parameters have been sent to the app chain.
event ParametersSent(uint256 indexed chainId, uint256 indexed messageNumber, uint256 nonce, string[] keys);
Parameters
| Name | Type | Description |
|---|---|---|
chainId | uint256 | The chain ID of the target app chain. |
messageNumber | uint256 | The message number, unique per inbox. |
nonce | uint256 | The nonce of the parameter transmission (to prevent out-of-sequence resets). |
keys | string[] | The keys of the parameters. |
InboxUpdated
Emitted when the inbox for a chain ID has been updated.
event InboxUpdated(uint256 indexed chainId, address indexed inbox);
Parameters
| Name | Type | Description |
|---|---|---|
chainId | uint256 | The chain ID. |
inbox | address | The inbox address. |
WithdrawalReceived
Emitted when fee tokens are withdrawn from the app chain.
event WithdrawalReceived(address indexed recipient, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
recipient | address | The recipient of the tokens. |
amount | uint256 | The amount of tokens withdrawn. |
PauseStatusUpdated
Emitted when the pause status is set.
event PauseStatusUpdated(bool indexed paused);
Parameters
| Name | Type | Description |
|---|---|---|
paused | bool | The new pause status. |
Errors
ZeroParameterRegistry
Thrown when the parameter registry address is zero (i.e. address(0)).
error ZeroParameterRegistry();
ZeroAppChainGateway
Thrown when the app chain gateway address is zero (i.e. address(0)).
error ZeroAppChainGateway();
ZeroFeeToken
Thrown when the fee token address is zero (i.e. address(0)).
error ZeroFeeToken();
TransferFromFailed
Thrown when the ERC20.transferFrom call fails.
This is an identical redefinition of SafeTransferLib.TransferFromFailed.
error TransferFromFailed();
NoChainIds
Thrown when no chain IDs are provided.
error NoChainIds();
NoKeys
Thrown when no keys are provided.
error NoKeys();
UnsupportedChainId
Thrown when the chain ID is not supported.
error UnsupportedChainId(uint256 chainId);
Paused
Thrown when any pausable function is called when the contract is paused.
error Paused();
NoChange
Thrown when there is no change to an updated parameter.
error NoChange();
ZeroBalance
Thrown when the balance is zero.
error ZeroBalance();
ZeroAmount
Thrown when the amount is zero.
error ZeroAmount();
ZeroRecipient
Thrown when the recipient is zero (i.e. address(0)).
error ZeroRecipient();
InvalidFeeTokenDecimals
Thrown when the fee token decimals are greater than 18.
error InvalidFeeTokenDecimals();
InsufficientAmount
Thrown when the amount is insufficient to cover the max submission and transaction costs.
error InsufficientAmount(uint256 appChainAmount, uint256 maxTotalCosts);