Client Library API Reference
On this page
Add Chainlink CCIP to your project
If you need to integrate Chainlink CCIP into your project, install the @chainlink-ccip/contracts NPM package .
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;
}
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.
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.
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 MATIC on Polygon. extraArgs bytes Users fill in the EVMExtraArgsV1 struct then encode it to bytes using the _argsToBytes function
bytes4 EVM_EXTRA_ARGS_V1_TAG
struct EVMExtraArgsV1 {
uint256 gasLimit;
bool strict;
}
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 for more details. strict bool Used for strict sequencing. Read Sequencing for more details
Experimental Feature
Strict sequencing : This feature is currently experimental. While we're actively evaluating its performance and
usefulness, we do not guarantee its maintenance or further development in the future.
Functions
_argsToBytes
function _argsToBytes ( struct Client . EVMExtraArgsV1 extraArgs) internal pure returns ( bytes bts)
Checks if the given chain ID is supported for sending/receiving.
Parameters
Name Type Description extraArgs Client.EVMExtraArgsV1 Extra arguments.
Return Values
Name Type Description bts bytes Encoded extra arguments in bytes .
More