Chainlink Local - Documentation
  • 💻Getting Started
    • Chainlink Local - Documentation
    • Architecture
  • 📖API Reference
    • API Reference
    • CCIPLocalSimulator.sol API
    • CCIPLocalSimulatorFork.sol API
    • CCIPLocalSimulatorFork.js API
    • MockV3Aggregator.sol API
    • MockOffchainAggregator.sol API
  • Guides
    • CCIPLocalSimulator.sol - usage with Foundry, Hardhat & Remix IDE
    • CCIPLocalSimulatorFork.sol - usage with Foundry
    • CCIPLocalSimulatorFork.js - usage with Hardhat
  • 🧑‍💻Learn more
    • Examples
    • Contribute to Chainlink Local
Powered by GitBook
On this page
  1. Guides

CCIPLocalSimulatorFork.sol - usage with Foundry

PreviousCCIPLocalSimulator.sol - usage with Foundry, Hardhat & Remix IDENextCCIPLocalSimulatorFork.js - usage with Hardhat

Last updated 1 year ago

Note: the RPC URLs here must point to .

Note also that in Foundry, , which may be different from what you've come to expect after using tools like Hardhat.

pragma solidity ^0.8.19;

import {CCIPLocalSimulatorFork} from "@chainlink/local/src/ccip/CCIPLocalSimulatorFork.sol";

contract Demo is Test {
    CCIPLocalSimulatorFork public ccipLocalSimulatorFork;

    uint256 sepoliaFork;
    uint256 arbSepoliaFork;

    function setUp() public {
        string memory ETHEREUM_SEPOLIA_RPC_URL = vm.envString("ETHEREUM_SEPOLIA_RPC_URL");
        string memory ARBITRUM_SEPOLIA_RPC_URL = vm.envString("ARBITRUM_SEPOLIA_RPC_URL");
        sepoliaFork = vm.createSelectFork(ETHEREUM_SEPOLIA_RPC_URL);
        arbSepoliaFork = vm.createFork(ARBITRUM_SEPOLIA_RPC_URL);

        ccipLocalSimulatorFork = new CCIPLocalSimulatorFork();
        vm.makePersistent(address(ccipLocalSimulatorFork));
    }

    function testDemo() public {
        sender.transferTokensPayLINK(arbSepoliaChainSelector, alice, address(ccipBnM), amountToSend);
        ccipLocalSimulatorFork.switchChainAndRouteMessage(arbSepoliaFork);
    }
}
archive nodes
Foundry Fork-Testing Guide
scripts are generally written in Solidity