# CCIPLocalSimulatorFork v0.2.1 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.2.1/ccip-local-simulator-fork-js

> For the complete documentation index, see [llms.txt](/llms.txt).

> **NOTE: Integrate Chainlink Local into your project**
>
> ### npm
>
> If you use [NPM](https://www.npmjs.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> npm install @chainlink/local@0.2.1
> ```
>
> ### yarn
>
> If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/local NPM
> package](https://www.npmjs.com/package/@chainlink/local):
>
> ```shell
> yarn add @chainlink/local@0.2.1
> ```
>
> ### foundry
>
> If you use [Foundry](https://book.getfoundry.sh/):
>
> ```shell
> forge install smartcontractkit/chainlink-local@ba1f4636e657f161df634379a5057a5a394e2fbb
> ```
>
> and then set remappings to: `@chainlink/local/=lib/chainlink-local/` in either `remappings.txt` or `foundry.toml` file
>
> ### RemixIDE
>
> Import the `CCIPLocalSimulator` contract from the `@chainlink/local` package:
>
> ```solidity
> import {CCIPLocalSimulator} from "@chainlink/local@0.2.1/src/ccip/CCIPLocalSimulator.sol";
> ```

## CCIPLocalSimulatorFork

[`CCIPLocalSimulatorFork`](https://github.com/smartcontractkit/chainlink-local/blob/main/scripts/CCIPLocalSimulatorFork.js) provides utilities for simulating Cross-Chain Interoperability Protocol (CCIP) operations in a forked environment. It enables testing of cross-chain messaging and token transfers within a Hardhat project.

## Types

### EVM2EVMMessage

An object representing a cross-chain message with the following structure:

| Property            | Type                                     | Description                            |
| ------------------- | ---------------------------------------- | -------------------------------------- |
| sourceChainSelector | `bigint`                                 | The chain selector of the source chain |
| sender              | `string`                                 | The address of the message sender      |
| receiver            | `string`                                 | The address of the message receiver    |
| sequenceNumber      | `bigint`                                 | Message sequence number                |
| gasLimit            | `bigint`                                 | Gas limit for message execution        |
| strict              | `boolean`                                | Whether strict mode is enabled         |
| nonce               | `bigint`                                 | Message nonce                          |
| feeToken            | `string`                                 | Address of the token used for fees     |
| feeTokenAmount      | `bigint`                                 | Amount of fee token                    |
| data                | `string`                                 | Message payload data                   |
| tokenAmounts        | `Array<{token: string, amount: bigint}>` | Array of token transfers               |
| sourceTokenData     | `Array<string>`                          | Source token metadata                  |
| messageId           | `string`                                 | Unique message identifier              |

## Functions

### requestLinkFromTheFaucet

Requests LINK tokens from a faucet contract for testing purposes.

| Parameter   | Type     | Description                                             |
| ----------- | -------- | ------------------------------------------------------- |
| linkAddress | `string` | The address of the LINK contract on the current network |
| to          | `string` | The address to receive the LINK tokens                  |
| amount      | `bigint` | The amount of LINK tokens to request                    |

**Returns**: `Promise<string>` - The transaction hash of the fund transfer

> **NOTE**
>
> The function uses a hardcoded faucet address and requires the ability to impersonate accounts in the forked
> environment.

### getEvm2EvmMessage

Parses a transaction receipt to extract CCIP message details from the `CCIPSendRequested` event.

| Parameter | Type     | Description                                      |
| --------- | -------- | ------------------------------------------------ |
| receipt   | `object` | The transaction receipt from the `ccipSend` call |

**Returns**: `object | null` - The parsed EVM2EVMMessage object or null if no valid message is found

> **TIP**
>
> This function is particularly useful for testing cross-chain message transmission and verification.

### routeMessage

Routes a sent message from the source network to the destination network in the forked environment.

| Parameter      | Type     | Description                                |
| -------------- | -------- | ------------------------------------------ |
| routerAddress  | `string` | Address of the destination Router contract |
| evm2EvmMessage | `object` | The cross-chain message to be routed       |

**Returns**: `Promise<void>` - Resolves when the message is successfully routed

> **CAUTION**
>
> This function will throw an error if:
>
> - No off-ramp matches the message's source chain selector
> - The call to `router.getOffRamps()` fails