Docs
Reference
Contract documentation
bridge
Bridge

Bridge

This contract is a Bridge contract which is deployed on both L1 and L2. Mostly a thin wrapper which calls the library implementations. See IBridge for more details.

The code hash for the same address on L1 and L2 may be different.

MessageStatusChanged

event MessageStatusChanged(bytes32 msgHash, enum LibBridgeStatus.MessageStatus status, address transactor)

DestChainEnabled

event DestChainEnabled(uint256 chainId, bool enabled)

receive

receive() external payable

Allow Bridge to receive ETH from the TaikoL1, TokenVault or EtherVault.

init

function init(address _addressManager) external

Initializer to be called after being deployed behind a proxy.

Initializer function to setup the EssentialContract.

Parameters

NameTypeDescription
_addressManageraddressThe address of the AddressManager contract.

sendMessage

function sendMessage(struct IBridge.Message message) external payable returns (bytes32 msgHash)

Sends a message from the current chain to the destination chain specified in the message.

Sends a message by calling the LibBridgeSend.sendMessage library function.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to send. (See IBridge)

Return Values

NameTypeDescription
msgHashbytes32The hash of the message that was sent.

releaseEther

function releaseEther(struct IBridge.Message message, bytes proof) external

Releases the Ether locked in the bridge as part of a cross-chain transfer.

Releases the Ether by calling the LibBridgeRelease.releaseEther library function.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message containing the details of the Ether transfer. (See IBridge)
proofbytesThe proof of the cross-chain transfer.

processMessage

function processMessage(struct IBridge.Message message, bytes proof) external

Processes a message received from another chain.

Processes the message by calling the LibBridgeProcess.processMessage library function.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to process.
proofbytesThe proof of the cross-chain transfer.

retryMessage

function retryMessage(struct IBridge.Message message, bool isLastAttempt) external

Retries sending a message that previously failed to send.

Retries the message by calling the LibBridgeRetry.retryMessage library function.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to retry.
isLastAttemptboolSpecifies whether this is the last attempt to send the message.

isMessageSent

function isMessageSent(bytes32 msgHash) public view virtual returns (bool)

Check if the message with the given hash has been sent.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.

Return Values

NameTypeDescription
[0]boolReturns true if the message has been sent, false otherwise.

isMessageReceived

function isMessageReceived(bytes32 msgHash, uint256 srcChainId, bytes proof) public view virtual returns (bool)

Check if the message with the given hash has been received.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.
srcChainIduint256The source chain ID.
proofbytesThe proof of message receipt.

Return Values

NameTypeDescription
[0]boolReturns true if the message has been received, false otherwise.

isMessageFailed

function isMessageFailed(bytes32 msgHash, uint256 destChainId, bytes proof) public view virtual returns (bool)

Check if the message with the given hash has failed.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.
destChainIduint256The destination chain ID.
proofbytesThe proof of message failure.

Return Values

NameTypeDescription
[0]boolReturns true if the message has failed, false otherwise.

getMessageStatus

function getMessageStatus(bytes32 msgHash) public view virtual returns (enum LibBridgeStatus.MessageStatus)

Get the status of the message with the given hash.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.

Return Values

NameTypeDescription
[0]enum LibBridgeStatus.MessageStatusReturns the status of the message.

context

function context() public view returns (struct IBridge.Context)

Get the current context

Return Values

NameTypeDescription
[0]struct IBridge.ContextReturns the current context.

isEtherReleased

function isEtherReleased(bytes32 msgHash) public view returns (bool)

Check if the Ether associated with the given message hash has been released.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.

Return Values

NameTypeDescription
[0]boolReturns true if the Ether has been released, false otherwise.

isDestChainEnabled

function isDestChainEnabled(uint256 _chainId) public view returns (bool enabled)

Check if the destination chain with the given ID is enabled.

Parameters

NameTypeDescription
_chainIduint256The ID of the chain.

Return Values

NameTypeDescription
enabledboolReturns true if the destination chain is enabled, false otherwise.

hashMessage

function hashMessage(struct IBridge.Message message) public pure returns (bytes32)

Compute the hash of a given message.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to compute the hash for.

Return Values

NameTypeDescription
[0]bytes32Returns the hash of the message.

getMessageStatusSlot

function getMessageStatusSlot(bytes32 msgHash) public pure returns (bytes32)

Get the slot associated with a given message hash status.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.

Return Values

NameTypeDescription
[0]bytes32Returns the slot associated with the given message hash status.

title: ProxiedBridge

ProxiedBridge