CCIPLocalSimulatorFork v0.2.2 API Reference
CCIPLocalSimulatorFork
A contract that simulates CCIP (Cross-Chain Interoperability Protocol) message routing in forked network environments, specifically designed to work with Foundry for testing cross-chain applications.
Events
CCIPSendRequested
event CCIPSendRequested(Internal.EVM2EVMMessage message)
Parameters
Parameter | Type | Description |
---|---|---|
message | Internal.EVM2EVMMessage | The EVM2EVM message that was sent |
Interfaces
IEVM2EVMOffRampFork
Interface for executing CCIP messages on the off-ramp.
interface IEVM2EVMOffRampFork {
function executeSingleMessage(
Internal.EVM2EVMMessage memory message,
bytes[] memory offchainTokenData,
uint32[] memory tokenGasOverrides
) external;
}
IRouterFork
Interface for accessing off-ramp configurations.
interface IRouterFork {
struct OffRamp {
uint64 sourceChainSelector;
address offRamp;
}
function getOffRamps() external view returns (OffRamp[] memory);
}
Structs
OffRamp
Configuration for a CCIP off-ramp.
struct OffRamp {
uint64 sourceChainSelector;
address offRamp;
}
Fields
Field | Type | Description |
---|---|---|
sourceChainSelector | uint64 | The chain selector for the source chain |
offRamp | address | The address of the offRamp contract |
Variables
i_register
Register immutable i_register
LINK_FAUCET
address constant LINK_FAUCET = 0x4281eCF07378Ee595C564a59048801330f3084eE
s_processedMessages
mapping(bytes32 messageId => bool isProcessed) internal s_processedMessages
Functions
constructor
Sets up the simulator environment by creating a persistent register instance and enabling event recording.
constructor()
getNetworkDetails
Fetches the network configuration for a specified blockchain network ID.
function getNetworkDetails(uint256 chainId) external view returns (Register.NetworkDetails memory)
Parameters
Parameter | Type | Description |
---|---|---|
chainId | uint256 | The blockchain network chain ID. For example 11155111 for Ethereum Sepolia. Not CCIP chain selector |
Returns
Parameter | Type | Description |
---|---|---|
networkDetails | Register.NetworkDetails | The tuple containing: chainSelector, routerAddress, linkAddress, wrappedNativeAddress, ccipBnMAddress, ccipLnMAddress |
requestLinkFromFaucet
Transfers LINK tokens from the faucet to a specified recipient address.
function requestLinkFromFaucet(address to, uint256 amount) external returns (bool success)
Parameters
Parameter | Type | Description |
---|---|---|
to | address | The address to which LINK tokens are to be sent |
amount | uint256 | The amount of LINK tokens to send |
Returns
Parameter | Type | Description |
---|---|---|
success | bool | Returns true if the transfer of tokens was successful, otherwise false |
setNetworkDetails
Registers or updates the network configuration for a specific blockchain.
function setNetworkDetails(uint256 chainId, Register.NetworkDetails memory networkDetails) external
Parameters
Parameter | Type | Description |
---|---|---|
chainId | uint256 | The blockchain network chain ID. For example 11155111 for Ethereum Sepolia. Not CCIP chain selector |
networkDetails | Register.NetworkDetails | The tuple containing: chainSelector, routerAddress, linkAddress, wrappedNativeAddress, ccipBnMAddress, ccipLnMAddress |
switchChainAndRouteMessage
Routes a cross-chain message by finding it in the event logs, switching to the destination chain, and executing it through the appropriate off-ramp.
function switchChainAndRouteMessage(uint256 forkId) external
Parameters
Parameter | Type | Description |
---|---|---|
forkId | uint256 | The ID of the destination network fork. This is the returned value of createFork() or createSelectFork() |