# Messenger

## Variables

### Message

```solidity
struct Message {
    bytes32 txUniqueIdentification;
    bytes32 crossType;
    bytes32 srcAnchor;
    bytes bnExtraFeed;
    bytes32 dstAnchor;
    bytes payload;
}
```

A properly defined struct to pack essential cross-chain information.

#### Params

<table><thead><tr><th width="269.3333333333333">Name</th><th width="103">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>txUniqueIdentification</code></td><td>bytes32</td><td>A globally unique identifier for each cross-chain message</td></tr><tr><td><code>crossType</code></td><td>bytes32</td><td>Indicate the type of a cross-chain message</td></tr><tr><td><code>srcAnchor</code></td><td>bytes32</td><td>The address of the source chain Anchor in bytes32</td></tr><tr><td><code>bnExtraFeed</code></td><td>bytes</td><td>Additional data that depends on the <code>crossType</code></td></tr><tr><td><code>dstAnchor</code></td><td>bytes32</td><td>The address of the destination chain Anchor in bytes32</td></tr><tr><td><code>payload</code></td><td>bytes</td><td>Application-level data that will be forwarded to the destination consumer contract</td></tr></tbody></table>

### MessageStatus

```solidity
enum MessageStatus {
    DELIVERED,
    FAILED
}
```

Returns `DELIVERED` when the cross-chain message has been successfully delivered to the destination. Otherwise, `FAILED` is signalled, along with an event `MessageCached` emitted.&#x20;

## Events

### MessageSent

```solidity
event MessageSent(Message message);
```

Emits on the source chain with essential cross-chain information packed in a `Message` struct.

### MessageReceived

```solidity
event MessageReceived(
    bytes32 txUniqueIdentification,
    bytes32 crossType,
    bytes32 srcAnchor,
    bytes32 dstAnchor,
    MessageStatus status
);
```

Emits on the destination chain where the `MessageStatus` can be either `DELIVERED` or `FAILED`.

### MessageCached

```solidity
event MessageCached(bytes reason, bytes payload)
```

Emits when the destination transaction reverted for some reason. A bridge builder should define the error logic in their application-level contracts.&#x20;

It can be combined with the corresponding `MessageReceived` event to recover the original message and identify the reverting reason.

## Functions

### sendToBool

```solidity
function sendToBool(
    address payable refundAddress,
    bytes32 crossType,
    bytes memory valueFeed,
    uint32 dstChainId,
    bytes32 dstAnchor,
    bytes calldata payload
) external payable onlyRegisteredAnchor returns (bytes32 txUniqueIdentification)
```

Called by registered Anchors to forward cross-chain messages to BOOLNetwork.

#### Params

<table><thead><tr><th width="183.33333333333331">Name</th><th width="175">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>refundAddress</code></td><td>address payable</td><td>The address to receive the rest of the pre-paid transaction fee</td></tr><tr><td><code>crossType</code></td><td>bytes32</td><td>Indicate the type of a cross-chain message</td></tr><tr><td><code>valueFeed</code></td><td>bytes</td><td>Additional data that depends on the <code>crossType</code></td></tr><tr><td><code>dstChainId</code></td><td>uint32</td><td>ID of the destination chain</td></tr><tr><td><code>dstAnchor</code></td><td>bytes32</td><td>The address of the destination chain Anchor in bytes32</td></tr><tr><td><code>payload</code></td><td>bytes</td><td>Application-level data that will be forwarded to the destination consumer contract</td></tr></tbody></table>

#### Return  Values

<table><thead><tr><th width="269.3333333333333">Name</th><th width="102">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>txUniqueIdentification</code></td><td>bytes32</td><td>A globally unique identifier for each cross-chain message</td></tr></tbody></table>

### receiveFromBool

```solidity
function receiveFromBool(
    Message memory message, 
    bytes calldata signature
)external payable returns (MessageStatus status)
```

Receives cross-chain messages from BOOLNetwork.

#### Params

<table><thead><tr><th width="201">Name</th><th width="112.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td>Message</td><td>A Message struct consists of all the essential cross-chain information</td></tr><tr><td><code>signature</code></td><td>bytes</td><td>Signature from a committee which is used to verify the validity of a cross-chain message</td></tr></tbody></table>

#### Return Values

<table><thead><tr><th width="130.33333333333331">Name</th><th width="156">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td>MessageStatus</td><td>An identifier to present the final status of a cross-chain message</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bool.network/evm-ecosystem/smart-contracts/primary-contracts/messenger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
