# CCIP v1.5.0 Client Library API Reference
Source: https://docs.chain.link/ccip/api-reference/evm/v1.5.0/client


<Aside type="note" title="Integrate Chainlink CCIP v1.5.0 into your project">
  <Tabs sharedStore="ccip-v1-5-0-package" client:visible>
    <Fragment slot="tab.1">npm</Fragment>
    <Fragment slot="tab.2">yarn</Fragment>
    <Fragment slot="tab.3">foundry</Fragment>

    <Fragment slot="panel.1">
      If you use [NPM](https://www.npmjs.com/), install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip):

      ```shell
      npm install @chainlink/contracts-ccip@1.5.0
      ```
    </Fragment>

    <Fragment slot="panel.2">
      If you use [Yarn](https://yarnpkg.com/), install the [@chainlink/contracts-ccip NPM package](https://www.npmjs.com/package/@chainlink/contracts-ccip):

      ```shell
      yarn add @chainlink/contracts-ccip@1.5.0
      ```
    </Fragment>

    <Fragment slot="panel.3">
      If you use [Foundry](https://book.getfoundry.sh/), install the package:

      ```shell
      forge install smartcontractkit/ccip@5c711214167b7e6f05cf6de74bdab9f6e26763b2
      ```
    </Fragment>
  </Tabs>
</Aside>

CCIP senders and receivers use the CCIP [`Client`](https://github.com/smartcontractkit/ccip/tree/release/contracts-ccip-1.5.0/contracts/src/v0.8/ccip/libraries/Client.sol) library to build CCIP messages.

```solidity
import { Client } from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
```

## Types and Constants

### EVMTokenAmount

Use this solidity struct to specify the token address and amount.

```solidity
struct EVMTokenAmount {
  address token;
  uint256 amount;
}
```

| Name   | Type    | Description                       |
| ------ | ------- | --------------------------------- |
| token  | address | token address on the local chain. |
| amount | uint256 | Amount of tokens.                 |

### Any2EVMMessage

CCIP receivers use this solidity struct to parse the received CCIP message.

```solidity
struct Any2EVMMessage {
  bytes32 messageId;
  uint64 sourceChainSelector;
  bytes sender;
  bytes data;
  struct Client.EVMTokenAmount[] destTokenAmounts;
}
```

| Name                | Type                     | Description                                                                          |
| ------------------- | ------------------------ | ------------------------------------------------------------------------------------ |
| messageId           | bytes32                  | CCIP messageId, generated on the source chain.                                       |
| sourceChainSelector | uint64                   | Source chain selector.                                                               |
| sender              | bytes                    | Sender address. `abi.decode(sender, (address))` if the source chain is an EVM chain. |
| data                | bytes                    | Payload sent within the CCIP message.                                                |
| destTokenAmounts    | Client.EVMTokenAmount\[] | Tokens and their amounts in their destination chain representation.                  |

### EVM2AnyMessage

CCIP senders use this solidity struct to build the CCIP message.

```solidity
struct EVM2AnyMessage {
  bytes receiver;
  bytes data;
  struct Client.EVMTokenAmount[] tokenAmounts;
  address feeToken;
  bytes extraArgs;
}
```

| Name         | Type                     | Description                                                                                                                      |
| ------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| receiver     | bytes                    | Receiver address. Use `abi.encode(sender)` to encode the address to *bytes*.                                                     |
| data         | bytes                    | Payload sent within the CCIP message.                                                                                            |
| tokenAmounts | Client.EVMTokenAmount\[] | Tokens and their amounts in the source chain representation.                                                                     |
| feeToken     | address                  | Address of feeToken. Set `address(0)` to pay in native gas tokens such as ETH on Ethereum or POL on Polygon.                     |
| extraArgs    | bytes                    | Users fill in the [EVMExtraArgs struct](#evmextraargs) then encode it to bytes using the [\_argsToBytes function](#_argstobytes) |

### EVM\_EXTRA\_ARGS\_TAG

#### EVM\_EXTRA\_ARGS\_V1\_TAG

> **NOTE**
>
> This version (v1) is maintained for backward compatibility. You can already switch to v2.

```solidity
bytes4 EVM_EXTRA_ARGS_V1_TAG
```

#### EVM\_EXTRA\_ARGS\_V2\_TAG

```solidity
bytes4 EVM_EXTRA_ARGS_V2_TAG
```

### EVMExtraArgs

#### EVMExtraArgsV1

> **NOTE**
>
> This version (v1) is maintained for backward compatibility. You can already switch to v2.

```solidity
struct EVMExtraArgsV1 {
  uint256 gasLimit;
}
```

| Name     | Type    | Description                                                                                                                                                                                                                          |
| -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| gasLimit | uint256 | specifies the maximum amount of gas CCIP can consume to execute `ccipReceive()` on the contract located on the destination blockchain. Read [Setting gasLimit](/ccip/concepts/best-practices/evm#setting-gaslimit) for more details. |

#### EVMExtraArgsV2

```solidity
struct EVMExtraArgsV2 {
  uint256 gasLimit;
  bool allowOutOfOrderExecution;
}
```

| Name                     | Type    | Description                                                                                                                                                                                                                                                                           |
| ------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| gasLimit                 | uint256 | specifies the maximum amount of gas CCIP can consume to execute `ccipReceive()` on the contract located on the destination blockchain. Read [Setting gasLimit](/ccip/concepts/best-practices/evm#setting-gaslimit) for more details.                                                  |
| allowOutOfOrderExecution | bool    | if true, it indicates that the message can be executed in any order relative to other messages from the same sender. This value's default varies by chain. On some chains, a particular value is enforced, meaning if the expected value is not set, the message request will revert. |

## Functions

### \_argsToBytes

#### \_argsToBytes (v1)

> **NOTE**
>
> This version (v1) is maintained for backward compatibility. You can already switch to v2.

```solidity
function _argsToBytes(struct Client.EVMExtraArgsV1 extraArgs) internal pure returns (bytes bts)
```

It is used to convert the arguments to bytes.

##### Parameters

| Name      | Type                                     | Description      |
| --------- | ---------------------------------------- | ---------------- |
| extraArgs | [Client.EVMExtraArgsV1](#evmextraargsv1) | Extra arguments. |

##### Return Values

| Name | Type  | Description                         |
| ---- | ----- | ----------------------------------- |
| bts  | bytes | Encoded extra arguments in *bytes*. |

#### \_argsToBytes (v2)

```solidity
function _argsToBytes(struct Client.EVMExtraArgsV2 extraArgs) internal pure returns (bytes bts)
```

It is used to convert the arguments to bytes.

##### Parameters

| Name      | Type                                     | Description      |
| --------- | ---------------------------------------- | ---------------- |
| extraArgs | [Client.EVMExtraArgsV2](#evmextraargsv2) | Extra arguments. |

##### Return Values

| Name | Type  | Description                         |
| ---- | ----- | ----------------------------------- |
| bts  | bytes | Encoded extra arguments in *bytes*. |