# `IMessageService`

### MessageSent

```solidity
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

| Name | Type | Description |
| ---- | ---- | ----------- |
| _from | address | The indexed sender address of the message (msg.sender). |
| _to | address | The indexed intended recipient address of the message on the other layer. |
| _fee | uint256 | The fee being being paid to deliver the message to the recipient in Wei. |
| _value | uint256 | The value being sent to the recipient in Wei. |
| _nonce | uint256 | The unique message number. |
| _calldata | bytes | The calldata being passed to the intended recipient when being called on claiming. |
| _messageHash | bytes32 | The indexed hash of the message parameters. |

### MessageClaimed

```solidity
event MessageClaimed(bytes32 _messageHash)
```

Emitted when a message is claimed.

#### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| _messageHash | bytes32 | The indexed hash of the message that was claimed. |

### FeeTooLow

```solidity
error FeeTooLow()
```

_Thrown when fees are lower than the minimum fee._

### ValueSentTooLow

```solidity
error ValueSentTooLow()
```

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

### MessageSendingFailed

```solidity
error MessageSendingFailed(address destination)
```

_Thrown when the destination address reverts._

### FeePaymentFailed

```solidity
error FeePaymentFailed(address recipient)
```

_Thrown when the recipient address reverts._

### sendMessage

```solidity
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

| Name | Type | Description |
| ---- | ---- | ----------- |
| _to | address | The destination address on the destination chain. |
| _fee | uint256 | The message service fee on the origin chain. |
| _calldata | bytes | The calldata used by the destination message service to call the destination contract. |

### claimMessage

```solidity
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

| Name | Type | Description |
| ---- | ---- | ----------- |
| _from | address | The msg.sender calling the origin message service. |
| _to | address | The destination address on the destination chain. |
| _fee | uint256 | The message service fee on the origin chain. |
| _value | uint256 | The value to be transferred to the destination address. |
| _feeRecipient | address payable | Address that will receive the fees. |
| _calldata | bytes | The calldata used by the destination message service to call/forward to the destination contract. |
| _nonce | uint256 | Unique message number. |

### sender

```solidity
function sender() external view returns (address originalSender)
```

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

#### Return Values

| Name | Type | Description |
| ---- | ---- | ----------- |
| originalSender | address | The original sender of the message on the origin layer. |

