Client Library API Reference

CCIP senders and receivers use the CCIP Client library to build CCIP messages.

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.

struct EVMTokenAmount {
  address token;
  uint256 amount;
}
NameTypeDescription
tokenaddresstoken address on the local chain.
amountuint256Amount of tokens.

Any2EVMMessage

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

struct Any2EVMMessage {
  bytes32 messageId;
  uint64 sourceChainSelector;
  bytes sender;
  bytes data;
  struct Client.EVMTokenAmount[] destTokenAmounts;
}
NameTypeDescription
messageIdbytes32CCIP messageId, generated on the source chain.
sourceChainSelectoruint64Source chain selector.
senderbytesSender address. abi.decode(sender, (address)) if the source chain is an EVM chain.
databytesPayload sent within the CCIP message.
destTokenAmountsClient.EVMTokenAmount[]Tokens and their amounts in their destination chain representation.

EVM2AnyMessage

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

struct EVM2AnyMessage {
  bytes receiver;
  bytes data;
  struct Client.EVMTokenAmount[] tokenAmounts;
  address feeToken;
  bytes extraArgs;
}
NameTypeDescription
receiverbytesReceiver address. Use abi.encode(sender) to encode the address to bytes.
databytesPayload sent within the CCIP message.
tokenAmountsClient.EVMTokenAmount[]Tokens and their amounts in the source chain representation.
feeTokenaddressAddress of feeToken. Set address(0) to pay in native gas tokens such as ETH on Ethereum or POL on Polygon.
extraArgsbytesUsers fill in the EVMExtraArgs struct then encode it to bytes using the _argsToBytes function

EVM_EXTRA_ARGS_TAG

EVM_EXTRA_ARGS_V1_TAG

bytes4 EVM_EXTRA_ARGS_V1_TAG

EVM_EXTRA_ARGS_V2_TAG

bytes4 EVM_EXTRA_ARGS_V2_TAG

EVMExtraArgs

EVMExtraArgsV1

struct EVMExtraArgsV1 {
  uint256 gasLimit;
}
NameTypeDescription
gasLimituint256specifies the maximum amount of gas CCIP can consume to execute ccipReceive() on the contract located on the destination blockchain. Read Setting gasLimit for more details.

EVMExtraArgsV2

struct EVMExtraArgsV2 {
  uint256 gasLimit;
  bool allowOutOfOrderExecution;
}
NameTypeDescription
gasLimituint256specifies the maximum amount of gas CCIP can consume to execute ccipReceive() on the contract located on the destination blockchain. Read Setting gasLimit for more details.
allowOutOfOrderExecutionboolif 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)

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

It is used to convert the arguments to bytes.

Parameters
NameTypeDescription
extraArgsClient.EVMExtraArgsV1Extra arguments.
Return Values
NameTypeDescription
btsbytesEncoded extra arguments in bytes.

_argsToBytes (v2)

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

It is used to convert the arguments to bytes.

Parameters
NameTypeDescription
extraArgsClient.EVMExtraArgsV2Extra arguments.
Return Values
NameTypeDescription
btsbytesEncoded extra arguments in bytes.

Get the latest Chainlink content straight to your inbox.