# CCIPLocalSimulator v0.2.3 API Reference
Source: https://docs.chain.link/chainlink-local/api-reference/v0.2.3/ccip-local-simulator

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

<Common callout="importPackage023" />

## CCIPLocalSimulator

A contract that simulates local CCIP (Cross-Chain Interoperability Protocol) operations for testing and development purposes.

[`CCIPLocalSimulator`](https://github.com/smartcontractkit/chainlink-local/blob/7d8b2f888e1f10c8841ccd9e0f4af0f5baf11dab/src/ccip/CCIPLocalSimulator.sol)

<Aside>This contract includes methods to manage supported tokens and configurations for local simulations.</Aside>

## Variables

### CHAIN\_SELECTOR

```solidity
uint64 constant CHAIN_SELECTOR = 16015286601757825753
```

<Aside>The unique CCIP Chain Selector constant</Aside>

### i\_ccipBnM

```solidity
BurnMintERC677Helper internal immutable i_ccipBnM
```

<Aside>The BurnMintERC677Helper instance for CCIP-BnM token</Aside>

### i\_ccipLnM

```solidity
BurnMintERC677Helper internal immutable i_ccipLnM
```

<Aside>The BurnMintERC677Helper instance for CCIP-LnM token</Aside>

### i\_linkToken

```solidity
LinkToken internal immutable i_linkToken
```

<Aside>The LINK token instance</Aside>

### i\_mockRouter

```solidity
MockCCIPRouter internal immutable i_mockRouter
```

<Aside>The mock CCIP router instance</Aside>

### i\_wrappedNative

```solidity
WETH9 internal immutable i_wrappedNative
```

<Aside>The wrapped native token instance</Aside>

### s\_supportedTokens

```solidity
address[] internal s_supportedTokens
```

<Aside>The list of supported token addresses</Aside>

## Errors

### CCIPLocalSimulator\_\_MsgSenderIsNotTokenOwner

```solidity
error CCIPLocalSimulator__MsgSenderIsNotTokenOwner()
```

### CCIPLocalSimulator\_\_RequiredRoleNotFound

```solidity
error CCIPLocalSimulator__RequiredRoleNotFound(address account, bytes32 role, address token)
```

## Functions

### configuration

Returns the configuration details for pre-deployed contracts and services needed for local CCIP simulations.

```solidity
function configuration() public view returns (uint64 chainSelector_, IRouterClient sourceRouter_, IRouterClient destinationRouter_, WETH9 wrappedNative_, LinkToken linkToken_, BurnMintERC677Helper ccipBnM_, BurnMintERC677Helper ccipLnM_)
```

<Aside>Returns configuration details for pre-deployed contracts and services needed for local CCIP simulations.</Aside>

#### Returns

| Parameter           | Type                   | Description                                              |
| ------------------- | ---------------------- | -------------------------------------------------------- |
| chainSelector\_     | `uint64`               | The unique CCIP Chain Selector                           |
| sourceRouter\_      | `IRouterClient`        | The source chain Router contract                         |
| destinationRouter\_ | `IRouterClient`        | The destination chain Router contract                    |
| wrappedNative\_     | `WETH9`                | The wrapped native token which can be used for CCIP fees |
| linkToken\_         | `LinkToken`            | The LINK token                                           |
| ccipBnM\_           | `BurnMintERC677Helper` | The ccipBnM token                                        |
| ccipLnM\_           | `BurnMintERC677Helper` | The ccipLnM token                                        |

### constructor

Initializes the contract with pre-deployed token instances.

```solidity
constructor()
```

<Aside>Constructor to initialize the contract and pre-deployed token instances</Aside>

### getSupportedTokens

Gets the list of supported token addresses for a given chain selector.

```solidity
function getSupportedTokens(uint64 chainSelector) external view returns (address[] memory tokens)
```

<Aside>Gets a list of token addresses that are supported for cross-chain transfers by the simulator.</Aside>

#### Parameters

| Parameter     | Type     | Description                    |
| ------------- | -------- | ------------------------------ |
| chainSelector | `uint64` | The unique CCIP Chain Selector |

#### Returns

| Parameter | Type        | Description                                                                    |
| --------- | ----------- | ------------------------------------------------------------------------------ |
| tokens    | `address[]` | Returns a list of token addresses that are supported for cross-chain transfers |

### isChainSupported

Checks if a given chain selector is supported.

```solidity
function isChainSupported(uint64 chainSelector) public pure returns (bool supported)
```

<Aside>Checks whether the provided `chainSelector` is supported by the simulator.</Aside>

#### Parameters

| Parameter     | Type     | Description                    |
| ------------- | -------- | ------------------------------ |
| chainSelector | `uint64` | The unique CCIP Chain Selector |

#### Returns

| Parameter | Type   | Description                                                   |
| --------- | ------ | ------------------------------------------------------------- |
| supported | `bool` | Returns true if `chainSelector` is supported by the simulator |

### requestLinkFromFaucet

Transfers LINK tokens from the faucet to a specified address.

```solidity
function requestLinkFromFaucet(address to, uint256 amount) external returns (bool success)
```

> \*\*NOTE\*\*
>
>
>
> Requests LINK tokens from the faucet. The provided amount of tokens are transferred to provided destination address.

#### Parameters

| Parameter | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| to        | `address` | The address to which LINK tokens are to be sent |
| amount    | `uint256` | The amount of LINK tokens to send               |

#### Returns

| Parameter | Type   | Description                                             |
| --------- | ------ | ------------------------------------------------------- |
| success   | `bool` | Returns `true` if the transfer of tokens was successful |

### supportNewTokenViaAccessControlDefaultAdmin

Adds a new token to supported tokens list via AccessControl's DEFAULT\_ADMIN\_ROLE.

```solidity
function supportNewTokenViaAccessControlDefaultAdmin(address tokenAddress) external
```

> \*\*NOTE\*\*
>
>
>
> Allows user to support any new token, besides CCIP BnM and CCIP LnM, for cross-chain transfers. The caller must have
> the DEFAULT\_ADMIN\_ROLE as defined by the contract itself.

#### Parameters

| Parameter    | Type      | Description                                                     |
| ------------ | --------- | --------------------------------------------------------------- |
| tokenAddress | `address` | The address of the token to add to the list of supported tokens |

> **CAUTION**
>
> **Possible Reverts**

- Reverts if the caller is not the admin of the token using OZ's AccessControl DEFAULT\_ADMIN\_ROLE

### supportNewTokenViaGetCCIPAdmin

Adds a new token to supported tokens list via CCIP admin role.

```solidity
function supportNewTokenViaGetCCIPAdmin(address tokenAddress) external
```

<Aside>Allows user to support any new token, besides CCIP BnM and CCIP LnM, for cross-chain transfers.</Aside>

#### Parameters

| Parameter    | Type      | Description                                                     |
| ------------ | --------- | --------------------------------------------------------------- |
| tokenAddress | `address` | The address of the token to add to the list of supported tokens |

> **CAUTION**
>
> **Possible Reverts**

- Reverts if token does not implement getCCIPAdmin() function
- Reverts if the caller is not the token CCIPAdmin

### supportNewTokenViaOwner

Adds a new token to supported tokens list via token owner.

```solidity
function supportNewTokenViaOwner(address tokenAddress) external
```

<Aside>Allows user to support any new token, besides CCIP BnM and CCIP LnM, for cross-chain transfers.</Aside>

#### Parameters

| Parameter    | Type      | Description                                                     |
| ------------ | --------- | --------------------------------------------------------------- |
| tokenAddress | `address` | The address of the token to add to the list of supported tokens |

> **CAUTION**
>
> **Possible Reverts**

- Reverts if token does not implement owner() function
- Reverts if the caller is not the token owner