Docs
Reference
Contract documentation
bridge
Bridge

Bridge

See the documentation for IBridge (opens in a new tab).

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

init

function init(address _addressManager) external

Initializes the contract.

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.

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to be sent.

Return Values

NameTypeDescription
msgHashbytes32The hash of the sent message.

processMessage

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

Processes a message received from another chain.

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 executing a message that previously failed on its destination chain.

Parameters

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

recallMessage

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

Recalls a failed message on its source chain

Parameters

NameTypeDescription
messagestruct IBridge.MessageThe message to be recalled.
proofbytesThe proof of message processing failure.

isMessageSent

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

Checks if the message with the given hash has been sent on its source chain.

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)

Checks if the message with the given hash has been received on its destination chain.

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)

Checks if a msgHash has failed on its destination chain.

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.

isMessageRecalled

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

Checks if a failed message has been recalled on its source chain.

Parameters

NameTypeDescription
msgHashbytes32The hash of the message.

Return Values

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

getMessageStatus

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

Gets the execution status of the message with the given hash on its destination chain.

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)

Gets the current context.

Return Values

NameTypeDescription
[0]struct IBridge.Context

isDestChainEnabled

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

Checks 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)

Computes 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)

Gets 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.

shouldCheckProof

function shouldCheckProof() internal pure virtual returns (bool)

Tells if we need to check real proof or it is a test.

Return Values

NameTypeDescription
[0]boolReturns true if real proof checking is required, otherwise false if it is a mock/test environment.

ProxiedBridge

Proxied version of the parent contract.