IRouterClient API Reference

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);
 }

Errors

UnsupportedDestinationChain

error UnsupportedDestinationChain(uint64 destChainSelector)

InsufficientFeeTokenAmount

error InsufficientFeeTokenAmount()

InvalidMsgValue

error InvalidMsgValue()

Functions

isChainSupported

function isChainSupported(uint64 chainSelector) external view returns (bool supported)

Checks if the given chain ID is supported for sending/receiving.

Parameters

NameTypeDescription
chainSelectoruint64The chain to check.

Return Values

NameTypeDescription
supportedboolis true if supported or false if not.

getSupportedTokens

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.

Parameters

NameTypeDescription
chainSelectoruint64The chainSelector.

Return Values

NameTypeDescription
tokensaddress[]The addresses of all supported tokens.

getFee

function getFee(uint64 destinationChainSelector, struct Client.EVM2AnyMessage message) external view returns (uint256 fee)

returns 0 fees on invalid message.

Parameters

NameTypeDescription
destinationChainSelectoruint64The destination chainSelector
messagestruct Client.EVM2AnyMessageThe cross-chain CCIP message, including data and/or tokens

Return Values

NameTypeDescription
feeuint256returns guaranteed execution fee for the specified message delivery to the destination chain

ccipSend

function ccipSend(uint64 destinationChainSelector, struct Client.EVM2AnyMessage message) external payable returns (bytes32)

Request a message to be sent to the destination chain.

Parameters

NameTypeDescription
destinationChainSelectoruint64The destination chain ID
messagestruct Client.EVM2AnyMessageThe cross-chain CCIP message, including data and/or tokens

Return Values

NameTypeDescription
[0]bytes32messageId The message ID

Get the latest Chainlink content straight to your inbox.