CCIP v1.5.0 Internal Library API Reference
Internal
A library for CCIP internal definitions common to multiple contracts. Provides core data structures and utilities for cross-chain message processing.
Errors
InvalidEVMAddress
error InvalidEVMAddress(bytes encodedAddress);
Parameters
| Name | Type | Description |
|---|---|---|
encodedAddress | bytes | The invalid encoded address |
Enums
MessageExecutionState
Enum listing the possible message execution states within the offRamp contract.
enum MessageExecutionState {
UNTOUCHED,
IN_PROGRESS,
SUCCESS,
FAILURE
}
OCRPluginType
CCIP OCR plugin type, used to separate execution & commit transmissions and configs.
enum OCRPluginType {
Commit,
Execution
}
Structs
PriceUpdates
A collection of token price and gas price updates.
struct PriceUpdates {
TokenPriceUpdate[] tokenPriceUpdates;
GasPriceUpdate[] gasPriceUpdates;
}
Properties
| Name | Type | Description |
|---|---|---|
tokenPriceUpdates | TokenPriceUpdate[] | Array of token price updates |
gasPriceUpdates | GasPriceUpdate[] | Array of gas price updates |
TokenPriceUpdate
Token price in USD.
struct TokenPriceUpdate {
address sourceToken;
uint224 usdPerToken;
}
Properties
| Name | Type | Description |
|---|---|---|
sourceToken | address | Source token address |
usdPerToken | uint224 | 1e18 USD per 1e18 of the smallest token denomination |
GasPriceUpdate
Gas price for a given chain in USD, its value may contain tightly packed fields.
struct GasPriceUpdate {
uint64 destChainSelector;
uint224 usdPerUnitGas;
}
Properties
| Name | Type | Description |
|---|---|---|
destChainSelector | uint64 | Destination chain selector |
usdPerUnitGas | uint224 | 1e18 USD per smallest unit (e.g. wei) of destination chain gas |
TimestampedPackedUint224
A timestamped uint224 value that can contain several tightly packed fields.
struct TimestampedPackedUint224 {
uint224 value;
uint32 timestamp;
}
Properties
| Name | Type | Description |
|---|---|---|
value | uint224 | Value in uint224, can contain packed fields |
timestamp | uint32 | Timestamp of the most recent price update |
PoolUpdate
Structure for token pool updates.
struct PoolUpdate {
address token;
address pool;
}
Properties
| Name | Type | Description |
|---|---|---|
token | address | The IERC20 token address |
pool | address | The token pool address |
SourceTokenData
Structure containing token-specific data from the source chain.
struct SourceTokenData {
bytes sourcePoolAddress;
bytes destTokenAddress;
bytes extraData;
uint32 destGasAmount;
}
Properties
| Name | Type | Description |
|---|---|---|
sourcePoolAddress | bytes | Source pool address, abi encoded (trusted) |
destTokenAddress | bytes | Destination token address, abi encoded for EVM chains (untrusted) |
extraData | bytes | Optional pool data transferred to destination chain |
destGasAmount | uint32 | Gas available for releaseOrMint and balanceOf calls on the offRamp |
ExecutionReportSingleChain
Report submitted by the execution DON at the execution phase (including chain selector data).
struct ExecutionReportSingleChain {
uint64 sourceChainSelector;
Any2EVMRampMessage[] messages;
bytes[][] offchainTokenData;
bytes32[] proofs;
uint256 proofFlagBits;
}
Properties
| Name | Type | Description |
|---|---|---|
sourceChainSelector | uint64 | Source chain selector for which report is submitted |
messages | Any2EVMRampMessage[] | Array of messages to execute |
offchainTokenData | bytes[][] | Bytes array for each message, per transferred token |
proofs | bytes32[] | Merkle proofs |
proofFlagBits | uint256 | Bitmap of proof flags |
ExecutionReport
Report submitted by the execution DON at the execution phase.
struct ExecutionReport {
EVM2EVMMessage[] messages;
bytes[][] offchainTokenData;
bytes32[] proofs;
uint256 proofFlagBits;
}
Properties
| Name | Type | Description |
|---|---|---|
messages | EVM2EVMMessage[] | Array of messages to execute |
offchainTokenData | bytes[][] | Bytes array for each message, per transferred token |
proofs | bytes32[] | Merkle proofs |
proofFlagBits | uint256 | Bitmap of proof flags |
EVM2EVMMessage
The cross chain message that gets committed to EVM chains.
struct EVM2EVMMessage {
uint64 sourceChainSelector;
address sender;
address receiver;
uint64 sequenceNumber;
uint256 gasLimit;
bool strict;
uint64 nonce;
address feeToken;
uint256 feeTokenAmount;
bytes data;
Client.EVMTokenAmount[] tokenAmounts;
bytes[] sourceTokenData;
bytes32 messageId;
}
Properties
| Name | Type | Description |
|---|---|---|
sourceChainSelector | uint64 | Chain selector of the source chain (not chainId) |
sender | address | Sender address on the source chain |
receiver | address | Receiver address on the destination chain |
sequenceNumber | uint64 | Sequence number, not unique across lanes |
gasLimit | uint256 | User supplied maximum gas for destination chain execution |
strict | bool | DEPRECATED |
nonce | uint64 | Nonce for this lane and sender, not unique across lanes |
feeToken | address | Fee token address |
feeTokenAmount | uint256 | Fee token amount |
data | bytes | Arbitrary data payload supplied by the message sender |
tokenAmounts | Client.EVMTokenAmount[] | Array of tokens and amounts to transfer |
sourceTokenData | bytes[] | Array of token data, one per token |
messageId | bytes32 | Hash of the message data |
RampMessageHeader
Family-agnostic header for OnRamp & OffRamp messages.
struct RampMessageHeader {
bytes32 messageId;
uint64 sourceChainSelector;
uint64 destChainSelector;
uint64 sequenceNumber;
uint64 nonce;
}
Properties
| Name | Type | Description |
|---|---|---|
messageId | bytes32 | Unique identifier generated with source chain's encoding scheme |
sourceChainSelector | uint64 | CCIP chain selector of the source chain (not chainId) |
destChainSelector | uint64 | CCIP chain selector of the destination chain (not chainId) |
sequenceNumber | uint64 | Sequence number, not unique across lanes |
nonce | uint64 | Nonce for this lane and sender, not unique across senders/lanes |
EVM2AnyTokenTransfer
Structure representing token transfers from EVM chains to any destination chain.
struct EVM2AnyTokenTransfer {
address sourcePoolAddress;
bytes destTokenAddress;
bytes extraData;
uint256 amount;
bytes destExecData;
}
Properties
| Name | Type | Description |
|---|---|---|
sourcePoolAddress | address | Source pool EVM address (trusted) |
destTokenAddress | bytes | EVM address of the destination token (untrusted) |
extraData | bytes | Optional pool data transferred to destination chain |
amount | uint256 | Amount of tokens to transfer |
destExecData | bytes | Destination chain execution data (e.g., gas amount for EVM chains) |
Any2EVMTokenTransfer
Structure representing token transfers from any source chain to EVM chains.
struct Any2EVMTokenTransfer {
bytes sourcePoolAddress;
address destTokenAddress;
uint32 destGasAmount;
bytes extraData;
uint256 amount;
}
Properties
| Name | Type | Description |
|---|---|---|
sourcePoolAddress | bytes | Source pool EVM address encoded to bytes (trusted) |
destTokenAddress | address | Address of destination token |
destGasAmount | uint32 | Gas available for releaseOrMint and transfer calls on the offRamp |
extraData | bytes | Optional pool data transferred to destination chain |
amount | uint256 | Amount of tokens to transfer |
Any2EVMRampMessage
Family-agnostic message routed to an OffRamp.
struct Any2EVMRampMessage {
RampMessageHeader header;
bytes sender;
bytes data;
address receiver;
uint256 gasLimit;
Any2EVMTokenTransfer[] tokenAmounts;
}
Properties
| Name | Type | Description |
|---|---|---|
header | RampMessageHeader | Message header with identifiers and routing information |
sender | bytes | Sender address on the source chain |
data | bytes | Arbitrary data payload supplied by the message sender |
receiver | address | Receiver address on the destination chain |
gasLimit | uint256 | User supplied maximum gas for destination chain execution |
tokenAmounts | Any2EVMTokenTransfer[] | Array of tokens and amounts to transfer |
EVM2AnyRampMessage
Family-agnostic message emitted from the OnRamp.
struct EVM2AnyRampMessage {
RampMessageHeader header;
address sender;
bytes data;
bytes receiver;
bytes extraArgs;
address feeToken;
uint256 feeTokenAmount;
uint256 feeValueJuels;
EVM2AnyTokenTransfer[] tokenAmounts;
}
Properties
| Name | Type | Description |
|---|---|---|
header | RampMessageHeader | Message header with identifiers and routing information |
sender | address | Sender address on the source chain |
data | bytes | Arbitrary data payload supplied by the message sender |
receiver | bytes | Receiver address on the destination chain |
extraArgs | bytes | Destination-chain specific args (e.g., gasLimit for EVM) |
feeToken | address | Token used to pay fees |
feeTokenAmount | uint256 | Amount of fee token paid |
feeValueJuels | uint256 | Fee amount denominated in Juels |
tokenAmounts | EVM2AnyTokenTransfer[] | Array of tokens and amounts to transfer |
MerkleRoot
Struct to hold a merkle root and an interval for a source chain.
struct MerkleRoot {
uint64 sourceChainSelector;
bytes onRampAddress;
uint64 minSeqNr;
uint64 maxSeqNr;
bytes32 merkleRoot;
}
Properties
| Name | Type | Description |
|---|---|---|
sourceChainSelector | uint64 | Remote source chain selector that the Merkle Root is scoped to |
onRampAddress | bytes | Generic onramp address (for EVM, use abi.encode) |
minSeqNr | uint64 | Minimum sequence number, inclusive |
maxSeqNr | uint64 | Maximum sequence number, inclusive |
merkleRoot | bytes32 | Merkle root covering the interval & source chain messages |
State Variables
GAS_FOR_CALL_EXACT_CHECK
uint16 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000;
MAX_RET_BYTES
uint16 internal constant MAX_RET_BYTES = 4 + 4 * 32;
MAX_BALANCE_OF_RET_BYTES
uint256 internal constant MAX_BALANCE_OF_RET_BYTES = 32;
GAS_PRICE_BITS
uint8 public constant GAS_PRICE_BITS = 112;
MESSAGE_FIXED_BYTES
uint256 public constant MESSAGE_FIXED_BYTES = 32 * 17;
MESSAGE_FIXED_BYTES_PER_TOKEN
uint256 public constant MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * ((1 + 3 * 3) + 2);
ANY_2_EVM_MESSAGE_FIXED_BYTES
uint256 public constant ANY_2_EVM_MESSAGE_FIXED_BYTES = 32 * 14;
ANY_2_EVM_MESSAGE_FIXED_BYTES_PER_TOKEN
uint256 public constant ANY_2_EVM_MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * 10;
EVM_2_EVM_MESSAGE_HASH
bytes32 internal constant EVM_2_EVM_MESSAGE_HASH = keccak256("EVM2EVMMessageHashV2");
ANY_2_EVM_MESSAGE_HASH
bytes32 internal constant ANY_2_EVM_MESSAGE_HASH = keccak256("Any2EVMMessageHashV1");
EVM_2_ANY_MESSAGE_HASH
bytes32 internal constant EVM_2_ANY_MESSAGE_HASH = keccak256("EVM2AnyMessageHashV1");
CHAIN_FAMILY_SELECTOR_EVM
bytes4 public constant CHAIN_FAMILY_SELECTOR_EVM = 0x2812d52c;
PRECOMPILE_SPACE
uint256 public constant PRECOMPILE_SPACE = 1024;
Functions
_hash (EVM2EVMMessage)
function _hash(
EVM2EVMMessage memory original,
bytes32 metadataHash
) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
original | EVM2EVMMessage | Message to hash |
metadataHash | bytes32 | Immutable metadata hash representing a lane with a fixed OnRamp |
Returns
| Name | Type | Description |
|---|---|---|
hashedMessage | bytes32 | Hashed message as a keccak256 |
_hash (Any2EVMRampMessage)
function _hash(
Any2EVMRampMessage memory original,
bytes memory onRamp
) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
original | Any2EVMRampMessage | OffRamp message to hash |
onRamp | bytes | OnRamp to hash the message with - used to compute the metadataHash |
Returns
| Name | Type | Description |
|---|---|---|
hashedMessage | bytes32 | Hashed message as a keccak256 |
_hash (EVM2AnyRampMessage)
function _hash(
EVM2AnyRampMessage memory original,
bytes32 metadataHash
) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
original | EVM2AnyRampMessage | OnRamp message to hash |
metadataHash | bytes32 | Hash preimage to ensure global uniqueness |
Returns
| Name | Type | Description |
|---|---|---|
hashedMessage | bytes32 | Hashed message as a keccak256 |
_validateEVMAddress
function _validateEVMAddress(
bytes memory encodedAddress
) internal pure returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
encodedAddress | bytes | The abi-encoded address to validate |
Returns
| Name | Type | Description |
|---|---|---|
address | address | The validated address if valid |