CCIPLocalSimulatorFork v0.2.1 API Reference
CCIPLocalSimulatorFork
CCIPLocalSimulatorFork
enables testing of CCIP cross-chain messaging in forked network environments. This contract provides essential utilities for configuring networks and simulating message routing between chains in a Foundry test environment.
Events
CCIPSendRequested
event CCIPSendRequested(Internal.EVM2EVMMessage message)
Emitted when a cross-chain message is requested to be sent through CCIP.
Variables
i_register
Register immutable i_register
Stores and manages network configuration details required for CCIP operations.
LINK_FAUCET
address constant LINK_FAUCET = 0x4281eCF07378Ee595C564a59048801330f3084eE
Provides test LINK tokens to addresses during testing.
s_processedMessages
mapping(bytes32 messageId => bool isProcessed) internal s_processedMessages
Prevents duplicate processing by tracking which messages have already been handled.
Functions
constructor
constructor() public
Initializes the simulator environment by deploying and configuring a persistent Register contract.
getNetworkDetails
function getNetworkDetails(uint256 chainId) external view returns (Register.NetworkDetails memory)
Retrieves network-specific CCIP configuration details. Use this function to access default settings or custom configurations for a given network.
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 | A struct containing: |
• chainSelector - The unique CCIP Chain Selector • routerAddress - The address of the CCIP Router contract • linkAddress - The address of the LINK token • wrappedNativeAddress - The address of the wrapped native token for CCIP fees • ccipBnMAddress - The address of the CCIP BnM token • ccipLnMAddress - The address of the CCIP LnM token |
requestLinkFromFaucet
function requestLinkFromFaucet(address to, uint256 amount) external returns (bool success)
Transfers LINK tokens from the faucet to a specified address for testing purposes.
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
function setNetworkDetails(uint256 chainId, Register.NetworkDetails memory networkDetails) external
Updates or adds CCIP configuration details for a specific blockchain network.
Parameters:
Parameter | Type | Description |
---|---|---|
chainId | uint256 | The blockchain network chain ID. For example 11155111 for Ethereum Sepolia. Not CCIP chain selector. |
networkDetails | Register.NetworkDetails | A struct containing: |
• chainSelector - The unique CCIP Chain Selector • routerAddress - The address of the CCIP Router contract • linkAddress - The address of the LINK token • wrappedNativeAddress - The address of the wrapped native token for CCIP fees • ccipBnMAddress - The address of the CCIP BnM token • ccipLnMAddress - The address of the CCIP LnM token |
switchChainAndRouteMessage
function switchChainAndRouteMessage(uint256 forkId) external
Processes a cross-chain message by switching to the destination fork and executing the message.
Parameters:
Parameter | Type | Description |
---|---|---|
forkId | uint256 | The ID of the destination network fork. This is the returned value of createFork() or createSelectFork() |