Skip to main content

ITokenBridge

InitializationData​

struct InitializationData {
address defaultAdmin;
address messageService;
address tokenBeacon;
uint256 sourceChainId;
uint256 targetChainId;
address[] reservedTokens;
struct IPermissionsManager.RoleAddress[] roleAddresses;
struct IPauseManager.PauseTypeRole[] pauseTypeRoles;
struct IPauseManager.PauseTypeRole[] unpauseTypeRoles;
}

TokenReserved​

event TokenReserved(address token)

Emitted when the token address is reserved.

Parameters​

NameTypeDescription
tokenaddressThe indexed token address.

ReservationRemoved​

event ReservationRemoved(address token)

Emitted when the token address reservation is removed.

Parameters​

NameTypeDescription
tokenaddressThe indexed token address.

CustomContractSet​

event CustomContractSet(address nativeToken, address customContract, address setBy)

Emitted when the custom token address is set.

Parameters​

NameTypeDescription
nativeTokenaddressThe indexed nativeToken token address.
customContractaddressThe indexed custom contract address.
setByaddressThe indexed address of who set the custom contract.

BridgingInitiated​

event BridgingInitiated(address sender, address recipient, address token, uint256 amount)

Emitted when token bridging is initiated.

DEPRECATED in favor of BridgingInitiatedV2.

Parameters​

NameTypeDescription
senderaddressThe indexed sender address.
recipientaddressThe recipient address.
tokenaddressThe indexed token address.
amountuint256The indexed token amount.

BridgingInitiatedV2​

event BridgingInitiatedV2(address sender, address recipient, address token, uint256 amount)

Emitted when token bridging is initiated.

Parameters​

NameTypeDescription
senderaddressThe indexed sender address.
recipientaddressThe indexed recipient address.
tokenaddressThe indexed token address.
amountuint256The token amount.

BridgingFinalized​

event BridgingFinalized(address nativeToken, address bridgedToken, uint256 amount, address recipient)

Emitted when token bridging is finalized.

DEPRECATED in favor of BridgingFinalizedV2.

Parameters​

NameTypeDescription
nativeTokenaddressThe indexed native token address.
bridgedTokenaddressThe indexed bridged token address.
amountuint256The indexed token amount.
recipientaddressThe recipient address.

BridgingFinalizedV2​

event BridgingFinalizedV2(address nativeToken, address bridgedToken, uint256 amount, address recipient)

Emitted when token bridging is finalized.

Parameters​

NameTypeDescription
nativeTokenaddressThe indexed native token address.
bridgedTokenaddressThe indexed bridged token address.
amountuint256The token amount.
recipientaddressThe indexed recipient address.

NewToken​

event NewToken(address token)

Emitted when a new token is seen being bridged on the origin chain for the first time.

Parameters​

NameTypeDescription
tokenaddressThe indexed token address.

NewTokenDeployed​

event NewTokenDeployed(address bridgedToken, address nativeToken)

Emitted when a new token is deployed.

Parameters​

NameTypeDescription
bridgedTokenaddressThe indexed bridged token address.
nativeTokenaddressThe indexed native token address.

RemoteTokenBridgeSet​

event RemoteTokenBridgeSet(address remoteTokenBridge, address setBy)

Emitted when the remote token bridge is set.

Parameters​

NameTypeDescription
remoteTokenBridgeaddressThe indexed remote token bridge address.
setByaddressThe indexed address that set the remote token bridge.

TokenDeployed​

event TokenDeployed(address token)

Emitted when the token is set as deployed.

This can be triggered by anyone calling confirmDeployment on the alternate chain.

Parameters​

NameTypeDescription
tokenaddressThe indexed token address.

DeploymentConfirmed​

event DeploymentConfirmed(address[] tokens, address confirmedBy)

Emitted when the token deployment is confirmed.

This can be triggered by anyone provided there is correctly mapped token data.

Parameters​

NameTypeDescription
tokensaddress[]The token address list.
confirmedByaddressThe indexed address confirming deployment.

MessageServiceUpdated​

event MessageServiceUpdated(address newMessageService, address oldMessageService, address setBy)

Emitted when the message service address is set.

Parameters​

NameTypeDescription
newMessageServiceaddressThe indexed new message service address.
oldMessageServiceaddressThe indexed old message service address.
setByaddressThe indexed address setting the new message service address.

ReservedToken​

error ReservedToken(address token)

Thrown when attempting to bridge a reserved token.

RemoteTokenBridgeAlreadySet​

error RemoteTokenBridgeAlreadySet(address remoteTokenBridge)

Thrown when the remote token bridge is already set.

AlreadyBridgedToken​

error AlreadyBridgedToken(address token)

Thrown when attempting to reserve an already bridged token.

InvalidPermitData​

error InvalidPermitData(bytes4 permitData, bytes4 permitSelector)

Thrown when the permit data is invalid.

PermitNotFromSender​

error PermitNotFromSender(address owner)

Thrown when the permit is not from the sender.

PermitNotAllowingBridge​

error PermitNotAllowingBridge(address spender)

Thrown when the permit does not grant spending to the bridge.

ZeroAmountNotAllowed​

error ZeroAmountNotAllowed(uint256 amount)

Thrown when the amount being bridged is zero.

NotReserved​

error NotReserved(address token)

Thrown when trying to unreserve a non-reserved token.

TokenNotDeployed​

error TokenNotDeployed(address token)

Thrown when trying to confirm deployment of a non-deployed token.

AlreadyBrigedToNativeTokenSet​

error AlreadyBrigedToNativeTokenSet(address token)

Thrown when trying to set a custom contract on a bridged token.

NativeToBridgedTokenAlreadySet​

error NativeToBridgedTokenAlreadySet(address token)

Thrown when trying to set a custom contract on an already set token.

StatusAddressNotAllowed​

error StatusAddressNotAllowed(address token)

Thrown when trying to set a token that is already either native, deployed or reserved.

DecimalsAreUnknown​

error DecimalsAreUnknown(address token)

Thrown when the decimals for a token cannot be determined.

TokenListEmpty​

error TokenListEmpty()

Thrown when the token list is empty.

bridgeTokenWithPermit​

function bridgeTokenWithPermit(address _token, uint256 _amount, address _recipient, bytes _permitData) external payable

Similar to bridgeToken function but allows to pass additional permit data to do the ERC20 approval in a single transaction.

Parameters​

NameTypeDescription
_tokenaddressThe address of the token to be bridged.
_amountuint256The amount of the token to be bridged.
_recipientaddressThe address that will receive the tokens on the other chain.
_permitDatabytesThe permit data for the token, if applicable.

completeBridging​

function completeBridging(address _nativeToken, uint256 _amount, address _recipient, uint256 _chainId, bytes _tokenMetadata) external

It can only be called from the Message Service. To finalize the bridging process, a user or postmen needs to use the claimMessage function of the Message Service to trigger the transaction.

Parameters​

NameTypeDescription
_nativeTokenaddressThe address of the token on its native chain.
_amountuint256The amount of the token to be received.
_recipientaddressThe address that will receive the tokens.
_chainIduint256The source chainId or target chaindId for this token
_tokenMetadatabytesAdditional data used to deploy the bridged token if it doesn't exist already.

confirmDeployment​

function confirmDeployment(address[] _tokens) external payable

Change the status to DEPLOYED to the tokens passed in parameter Will call the method setDeployed on the other chain using the message Service

Parameters​

NameTypeDescription
_tokensaddress[]Array of bridged tokens that have been deployed.

setMessageService​

function setMessageService(address _messageService) external

Change the address of the Message Service.

Parameters​

NameTypeDescription
_messageServiceaddressThe address of the new Message Service.

setDeployed​

function setDeployed(address[] _nativeTokens) external

It can only be called from the Message Service. To change the status of the native tokens to DEPLOYED meaning they have been deployed on the other chain a user or postman needs to use the claimMessage function of the Message Service to trigger the transaction.

Parameters​

NameTypeDescription
_nativeTokensaddress[]The addresses of the native tokens.

setReserved​

function setReserved(address _token) external

Make sure that _token is native to the current chain where you are calling this function from

Linea can reserve tokens. In this case, the token cannot be bridged. Linea can only reserve tokens that have not been bridged before.

Parameters​

NameTypeDescription
_tokenaddressThe address of the token to be set as reserved.

setRemoteTokenBridge​

function setRemoteTokenBridge(address _remoteTokenBridge) external

Sets the address of the remote token bridge. Can only be called once.

Parameters​

NameTypeDescription
_remoteTokenBridgeaddressThe address of the remote token bridge to be set.

removeReserved​

function removeReserved(address _token) external

Removes a token from the reserved list.

Parameters​

NameTypeDescription
_tokenaddressThe address of the token to be removed from the reserved list.

setCustomContract​

function setCustomContract(address _nativeToken, address _targetContract) external

Linea can set a custom ERC20 contract for specific ERC20. For security purpose, Linea can only call this function if the token has not been bridged yet.

Parameters​

NameTypeDescription
_nativeTokenaddressaddress of the token on the source chain.
_targetContractaddressaddress of the custom contract.
Contributions not accepted
These reference pages are automatically generated based on Linea's smart contracts. To ensure they accurately match the deployed smart contracts, we cannot accept any contributions that edit these pages.