IRouterClient API Reference Add Chainlink CCIP to your project
If you need to integrate Chainlink CCIP into your project, install the @chainlink/contracts-ccip NPM package .
If you use NPM :
npm install @chainlink/contracts-ccip --save
If you use Yarn :
yarn add @chainlink/contracts-ccip
To send messages through CCIP, users must interact with the IRouterClient
interface.
After you import IRouterClient.sol
, you can initialize a router client instance:
import { IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol" ;
. . .
IRouterClient router;
constructor ( address _router) {
router = IRouterClient ( _router) ;
}
error UnsupportedDestinationChain ( uint64 destChainSelector)
error InsufficientFeeTokenAmount ( )
error InvalidMsgValue ( )
function isChainSupported ( uint64 chainSelector) external view returns ( bool supported)
Checks if the given chain ID is supported for sending/receiving.
Name Type Description chainSelector uint64 The chain to check.
Name Type Description supported bool is true if supported or false if not.
function getSupportedTokens ( uint64 chainSelector) external view returns ( address [ ] tokens)
Gets a list of all supported tokens which can be sent or received
to or from a given chain ID.
Name Type Description chainSelector uint64 The chainSelector.
Name Type Description tokens address[] The addresses of all supported tokens.
function getFee ( uint64 destinationChainSelector, struct Client . EVM2AnyMessage message) external view returns ( uint256 fee)
returns 0 fees on invalid message.
Name Type Description destinationChainSelector uint64 The destination chainSelector message struct Client.EVM2AnyMessage The cross-chain CCIP message, including data and/or tokens
Name Type Description fee uint256 returns guaranteed execution fee for the specified message delivery to the destination chain
function ccipSend ( uint64 destinationChainSelector, struct Client . EVM2AnyMessage message) external payable returns ( bytes32 )
Request a message to be sent to the destination chain.
Name Type Description destinationChainSelector uint64 The destination chain ID message struct Client.EVM2AnyMessage The cross-chain CCIP message, including data and/or tokens
Name Type Description [0] bytes32 messageId The message ID