CCIP v2.0.0 Client API Reference
Client defines the canonical CCIP message format and encoding helpers used by applications.
It provides:
- message structs for sending and receiving cross-chain messages
- encoding utilities for chain-specific execution parameters (
extraArgs) - common types used across Router, OnRamp, and OffRamp interactions
All CCIP message construction and decoding relies on this library.
This library provides reusable helper functions and is not deployed as a standalone application-facing contract.
Usage Boundary
You use this library when constructing or decoding CCIP messages.
- Applications use
EVM2AnyMessageto send messages through the Router. - Receiver contracts use
Any2EVMMessageto process inbound messages. - You are responsible for encoding
extraArgscorrectly for the destination chain.
Contract
libraries/Client.sol
Import
import {Client} from "chainlink-ccip/libraries/Client.sol";
If you have not installed the package:
npm install @chainlink/contracts-ccip@2.0.0
Functions
_argsToBytes
function _argsToBytes(EVMExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts)
Encodes extra arguments into the format expected by CCIP contracts.
_argsToBytes
function _argsToBytes(GenericExtraArgsV2 memory extraArgs) internal pure returns (bytes memory bts)
Encodes extra arguments into the format expected by CCIP contracts.
_svmArgsToBytes
function _svmArgsToBytes(SVMExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts)
Encodes SVM-specific execution arguments.
_suiArgsToBytes
function _suiArgsToBytes(SuiExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts)
Encodes Sui-specific execution arguments.
Constants
EVM_EXTRA_ARGS_V1_TAG
Version tag for EVMExtraArgsV1 encoding.
GENERIC_EXTRA_ARGS_V2_TAG
Version tag for GenericExtraArgsV2 encoding.
SVM_EXTRA_ARGS_V1_TAG
Version tag for SVMExtraArgsV1 encoding.
NO_EXECUTION_ADDRESS
address public constant NO_EXECUTION_ADDRESS = address(bytes20(NO_EXECUTION_TAG));
Special address used to indicate that no receiver execution should occur.
Structs
EVM2AnyMessage
| Field | Type |
|---|---|
receiver | bytes |
data | bytes |
tokenAmounts | EVMTokenAmount[] |
feeToken | address |
extraArgs | bytes |
EVMTokenAmount
| Field | Type |
|---|---|
token | address |
amount | uint256 |
Any2EVMMessage
| Field | Type |
|---|---|
messageId | bytes32 |
sourceChainSelector | uint64 |
sender | bytes |
data | bytes |
destTokenAmounts | EVMTokenAmount[] |
EVMExtraArgsV1
| Field | Type |
|---|---|
gasLimit | uint256 |
GenericExtraArgsV2
| Field | Type |
|---|---|
gasLimit | uint256 |
allowOutOfOrderExecution | bool |
SVMExtraArgsV1
| Field | Type |
|---|---|
computeUnits | uint32 |
accountIsWritableBitmap | uint64 |
allowOutOfOrderExecution | bool |
tokenReceiver | bytes32 |
accounts | bytes32[] |
SuiExtraArgsV1
| Field | Type |
|---|---|
gasLimit | uint256 |
allowOutOfOrderExecution | bool |
tokenReceiver | bytes32 |
receiverObjectIds | bytes32[] |
Notes
extraArgsmust match the destination chain’s expected format.- Different chain families (EVM, SVM, Sui) require different extra argument encodings.
- Incorrectly encoded
extraArgsmay cause message execution to revert.
Usage context
Used by:
Example:
// Construct outbound CCIP message
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(receiverAddress),
data: abi.encode(payload),
tokenAmounts: tokenAmounts,
feeToken: address(0),
extraArgs: Client._argsToBytes(
Client.GenericExtraArgsV2({
gasLimit: 300_000,
allowOutOfOrderExecution: false
})
)
});