CCIP v2.0.0 IRouterClient API Reference
IRouterClient defines the core interface for pricing and sending CCIP messages through the Router.
If you use this interface, you decide where to send the message, what payload and tokens to include, how fees are paid, and when to initiate delivery.
Most applications interact with the Router through deployed Router contracts. This interface defines the callable surface but does not implement routing logic.
Usage Boundary
You use this interface to construct, price, and send CCIP messages.
- Call
isChainSupportedto confirm the destination chain is available. - Construct an
EVM2AnyMessagewith your desired payload, receiver, tokens, and fee token. - Call
getFeeto estimate the cost of that message. - Call
ccipSendwith sufficient payment to send the message. - You are responsible for message correctness and fee sufficiency.
Contract
interfaces/IRouterClient.sol
Import
import {IRouterClient} from "chainlink-ccip/interfaces/IRouterClient.sol";
If you have not installed the package:
npm install @chainlink/contracts-ccip@2.0.0
External API
isChainSupported
function isChainSupported( uint64 destChainSelector ) external view returns (bool supported)
Checks whether the Router supports the specified destination chain.
| Parameter | Type | Description |
|---|---|---|
destChainSelector | uint64 | Identifier of the destination chain. |
Returns:
| Type | Description |
|---|---|
bool | True if the destination chain is supported. |
getFee
function getFee(
uint64 destinationChainSelector,
Client.EVM2AnyMessage memory message
) external view returns (
uint256 fee
)
Returns the fee required to send a message with the specified parameters.
You define the message contents and fee token, and this function returns the cost based on those inputs. Use this value to determine how much to approve or send when calling
ccipSend.
| Parameter | Type | Description |
|---|---|---|
destinationChainSelector | uint64 | Identifier of the destination chain. |
message | Client.EVM2AnyMessage memory | Message configuration including receiver, data payload, tokens, and fee token. |
Returns:
| Type | Description |
|---|---|
uint256 | Fee required to send the message, denominated in the specified feeToken. |
ccipSend
function ccipSend(
uint64 destinationChainSelector,
Client.EVM2AnyMessage calldata message
) external payable returns (
bytes32
)
Sends a cross-chain message through the Router.
You provide the message configuration and payment, and the Router initiates delivery to the destination chain.
This call commits the message for execution. If the message is invalid or the provided fee is insufficient, the transaction will revert.
| Parameter | Type | Description |
|---|---|---|
destinationChainSelector | uint64 | Identifier of the destination chain. |
message | Client.EVM2AnyMessage calldata | Message configuration including receiver, data payload, tokens, and fee token. |
Returns:
| Type | Description |
|---|---|
bytes32 | Unique identifier for the submitted message. |
Events
No new events declared.
For a cross-contract event index, see Events.
Errors
UnsupportedDestinationChain
Thrown when you attempt to send a message to a destination chain the Router does not support.
error UnsupportedDestinationChain(uint64 destChainSelector);
InsufficientFeeTokenAmount
Thrown when the fee token amount provided for the message is insufficient.
error InsufficientFeeTokenAmount();
InvalidMsgValue
Thrown when msg.value does not match the fee payment requirements for the message.
error InvalidMsgValue();
For a cross-contract error index, see Errors.
Notes
- You must construct a valid
EVM2AnyMessagebefore callinggetFeeorccipSend. - The fee returned by
getFeedepends on the message contents, destination chain, and selected fee token. - The fee returned by
getFeeis specific to the exact message parameters. Changing the message requires re-quoting the fee. ccipSendreverts if the destination chain is unsupported or if the provided fee is insufficient.- When paying fees in native tokens (
feeToken == address(0)), you must provide sufficientmsg.value. - If you send excess
msg.value, the Router determines how that excess is handled.