Skip to main content

IMessageService

MessageSent​

event MessageSent(address _from, address _to, uint256 _fee, uint256 _value, uint256 _nonce, bytes _calldata, bytes32 _messageHash)

Emitted when a message is sent.

_calldata has the _ because calldata is a reserved word. We include the message hash to save hashing costs on the rollup. This event is used on both L1 and L2.

Parameters​

NameTypeDescription
_fromaddressThe indexed sender address of the message (msg.sender).
_toaddressThe indexed intended recipient address of the message on the other layer.
_feeuint256The fee being being paid to deliver the message to the recipient in Wei.
_valueuint256The value being sent to the recipient in Wei.
_nonceuint256The unique message number.
_calldatabytesThe calldata being passed to the intended recipient when being called on claiming.
_messageHashbytes32The indexed hash of the message parameters.

MessageClaimed​

event MessageClaimed(bytes32 _messageHash)

Emitted when a message is claimed.

Parameters​

NameTypeDescription
_messageHashbytes32The indexed hash of the message that was claimed.

FeeTooLow​

error FeeTooLow()

Thrown when fees are lower than the minimum fee.

ValueSentTooLow​

error ValueSentTooLow()

_Thrown when the value sent is less than the fee. Value to forward on is msg.value - fee.

MessageSendingFailed​

error MessageSendingFailed(address destination)

Thrown when the destination address reverts.

FeePaymentFailed​

error FeePaymentFailed(address recipient)

Thrown when the recipient address reverts.

sendMessage​

function sendMessage(address _to, uint256 _fee, bytes _calldata) external payable

Sends a message for transporting from the given chain.

_This function should be called with a msg.value = _value + fee. The fee will be paid on the destination chain.

Parameters​

NameTypeDescription
_toaddressThe destination address on the destination chain.
_feeuint256The message service fee on the origin chain.
_calldatabytesThe calldata used by the destination message service to call the destination contract.

claimMessage​

function claimMessage(address _from, address _to, uint256 _fee, uint256 _value, address payable _feeRecipient, bytes _calldata, uint256 _nonce) external

Deliver a message to the destination chain. Is called by the Postman, dApp or end user.

Parameters​

NameTypeDescription
_fromaddressThe msg.sender calling the origin message service.
_toaddressThe destination address on the destination chain.
_feeuint256The message service fee on the origin chain.
_valueuint256The value to be transferred to the destination address.
_feeRecipientaddress payableAddress that will receive the fees.
_calldatabytesThe calldata used by the destination message service to call/forward to the destination contract.
_nonceuint256Unique message number.

sender​

function sender() external view returns (address originalSender)

Returns the original sender of the message on the origin layer.

Return Values​

NameTypeDescription
originalSenderaddressThe original sender of the message on the origin layer.

Was this page helpful?