> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/eco/eco-routes/llms.txt
> Use this file to discover all available pages before exploring further.

# Inbox

> Contract for fulfilling intents on the destination chain

## Overview

The Inbox contract is the main entry point for fulfilling intents on the destination chain. It validates intent hash authenticity, executes calldata, and enables provers to claim rewards on the source chain by checking the claimants mapping.

**Contract Location:** `contracts/Inbox.sol`

**Inherits:** DestinationSettler, IInbox

## State Variables

### claimants

```solidity theme={null}
mapping(bytes32 => bytes32) public claimants
```

Mapping of intent hashes to their claimant identifiers. Stores the cross-VM compatible claimant identifier for each fulfilled intent.

### executor

```solidity theme={null}
IExecutor public immutable executor
```

Reference to the Executor contract used to execute intent calls.

## State-Changing Functions

### fulfill

```solidity theme={null}
function fulfill(
    bytes32 intentHash,
    Route memory route,
    bytes32 rewardHash,
    bytes32 claimant
) external payable returns (bytes[] memory)
```

Fulfills an intent to be proven via storage proofs. Validates intent hash, executes calls, and marks as fulfilled.

<ParamField path="intentHash" type="bytes32">
  The hash of the intent to fulfill
</ParamField>

<ParamField path="route" type="Route">
  The route of the intent containing execution instructions
</ParamField>

<ParamField path="rewardHash" type="bytes32">
  The hash of the reward details
</ParamField>

<ParamField path="claimant" type="bytes32">
  Cross-VM compatible claimant identifier
</ParamField>

<ResponseField name="bytes[]" type="bytes[]">
  Array of execution results from each call
</ResponseField>

<Note>
  This function is payable and requires msg.value to be at least route.nativeAmount. Any excess ETH is automatically refunded to the caller.
</Note>

***

### fulfillAndProve

```solidity theme={null}
function fulfillAndProve(
    bytes32 intentHash,
    Route memory route,
    bytes32 rewardHash,
    bytes32 claimant,
    address prover,
    uint64 sourceChainDomainID,
    bytes memory data
) public payable returns (bytes[] memory)
```

Fulfills an intent and initiates proving in one transaction. Executes intent actions and sends proof message to source chain.

<ParamField path="intentHash" type="bytes32">
  The hash of the intent to fulfill
</ParamField>

<ParamField path="route" type="Route">
  The route of the intent
</ParamField>

<ParamField path="rewardHash" type="bytes32">
  The hash of the reward details
</ParamField>

<ParamField path="claimant" type="bytes32">
  Cross-VM compatible claimant identifier
</ParamField>

<ParamField path="prover" type="address">
  Address of prover on the destination chain
</ParamField>

<ParamField path="sourceChainDomainID" type="uint64">
  Domain ID of the source chain where the intent was created
</ParamField>

<ParamField path="data" type="bytes">
  Additional data for message formatting
</ParamField>

<ResponseField name="bytes[]" type="bytes[]">
  Array of execution results
</ResponseField>

<Warning>
  **WARNING:** `sourceChainDomainID` is NOT necessarily the same as chain ID.

  Each bridge provider uses their own domain ID mapping system:

  * **Hyperlane**: Uses custom domain IDs that may differ from chain IDs
  * **LayerZero**: Uses endpoint IDs that map to chains differently
  * **Metalayer**: Uses domain IDs specific to their routing system
  * **Polymer**: Uses chain IDs

  You MUST consult the specific bridge provider's documentation to determine the correct domain ID for the source chain.
</Warning>

***

### prove

```solidity theme={null}
function prove(
    address prover,
    uint64 sourceChainDomainID,
    bytes32[] memory intentHashes,
    bytes memory data
) public payable
```

Initiates proving process for fulfilled intents. Sends message to source chain to verify intent execution.

<ParamField path="prover" type="address">
  Address of prover on the destination chain
</ParamField>

<ParamField path="sourceChainDomainID" type="uint64">
  Domain ID of the source chain
</ParamField>

<ParamField path="intentHashes" type="bytes32[]">
  Array of intent hashes to prove
</ParamField>

<ParamField path="data" type="bytes">
  Additional data for message formatting
</ParamField>

<Warning>
  **WARNING:** `sourceChainDomainID` is NOT necessarily the same as chain ID.

  Each bridge provider uses their own domain ID mapping system:

  * **Hyperlane**: Uses custom domain IDs that may differ from chain IDs
  * **LayerZero**: Uses endpoint IDs that map to chains differently
  * **Metalayer**: Uses domain IDs specific to their routing system
  * **Polymer**: Uses chain IDs

  You MUST consult the specific bridge provider's documentation to determine the correct domain ID for the source chain.
</Warning>

<Note>
  This function can only prove intents that have already been fulfilled. It will revert with IntentNotFulfilled if any of the provided intent hashes have not been fulfilled yet.
</Note>

## Events

### IntentFulfilled

```solidity theme={null}
event IntentFulfilled(
    bytes32 indexed intentHash,
    bytes32 indexed claimant
)
```

Emitted when an intent is successfully fulfilled.

### IntentProven

```solidity theme={null}
event IntentProven(
    bytes32 indexed intentHash,
    bytes32 indexed claimant
)
```

Emitted when an intent proof is submitted to the prover.

## Errors

### ChainIdTooLarge

```solidity theme={null}
error ChainIdTooLarge(uint256 chainId)
```

Thrown when the chain ID exceeds uint64 maximum value.

### IntentExpired

```solidity theme={null}
error IntentExpired()
```

Thrown when attempting to fulfill an intent after its deadline.

### InvalidPortal

```solidity theme={null}
error InvalidPortal(address portal)
```

Thrown when the route.portal does not match the current contract address.

### InvalidHash

```solidity theme={null}
error InvalidHash(bytes32 intentHash)
```

Thrown when the computed intent hash does not match the provided intent hash.

### IntentAlreadyFulfilled

```solidity theme={null}
error IntentAlreadyFulfilled(bytes32 intentHash)
```

Thrown when attempting to fulfill an intent that has already been fulfilled.

### ZeroClaimant

```solidity theme={null}
error ZeroClaimant()
```

Thrown when the claimant is bytes32(0).

### InsufficientNativeAmount

```solidity theme={null}
error InsufficientNativeAmount(uint256 provided, uint256 required)
```

Thrown when msg.value is less than route.nativeAmount.

### IntentNotFulfilled

```solidity theme={null}
error IntentNotFulfilled(bytes32 intentHash)
```

Thrown when attempting to prove an intent that has not been fulfilled.

## Usage Example

```solidity theme={null}
// Fulfill an intent
bytes[] memory results = inbox.fulfill{
    value: route.nativeAmount
}(
    intentHash,
    route,
    rewardHash,
    claimant
);

// Or fulfill and prove in one transaction
bytes[] memory results = inbox.fulfillAndProve{
    value: route.nativeAmount + provingFee
}(
    intentHash,
    route,
    rewardHash,
    claimant,
    proverAddress,
    sourceChainDomainID,
    proofData
);
```
