NEW

CCIP is now live for all developers. See what's new.

CCIP local simulator

You can use Chainlink Local to run CCIP in a localhost environment in any smart contract development framework. This guide explains how to set up local simulator mode to test CCIP locally in Foundry, Hardhat and Remix IDE.

To set up local simulator mode:

  1. Import the CCIPLocalSimulator.sol singleton contract from the @chainlink/local package.
  2. Deploy it on your local development network.

After deployment, the simulator is ready to use.

Using Foundry or Hardhat

pragma solidity ^0.8.19;

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

contract Demo is Test {
CCIPLocalSimulator public ccipLocalSimulator;

    function setUp() public {
        ccipLocalSimulator = new CCIPLocalSimulator();

        (
            uint64 chainSelector,
            IRouterClient sourceRouter,
            IRouterClient destinationRouter,
            WETH9 wrappedNative,
            LinkToken linkToken,
            BurnMintERC677Helper ccipBnM,
            BurnMintERC677Helper ccipLnM
        ) = ccipLocalSimulator.configuration();

    }

}

Using Remix IDE

  1. Create a file named CCIPLocalSimulator.sol and paste the following code:

    pragma solidity ^0.8.19;
    
    import { CCIPLocalSimulator } from "https://github.com/smartcontractkit/chainlink-local/blob/main/src/ccip/CCIPLocalSimulator.sol";
    
  2. Compile it and deploy it to Remix VM.

    If deployment fails, go back to the Solidity Compile tab, expand the Advanced Configuration menu, and under Compiler configuration, check the Enable optimization check box. Compile it and try deploying it again.

  3. Call the configuration() function to display all the addresses you need to deploy your smart contracts, such as the Router and LinkToken addresses:

    Calling the configuration function
  4. Deploy your smart contracts using the addresses shown by the configuration() function. After you deploy your smart contracts, the simulator is set up and ready for you to start testing your smart contracts.

    If you encounter the NotEnoughGasForCall custom error provided by the Router smart contract, scroll up to the Gas Limit section, select the Custom radio button and try again.

    Setting a custom gas limit

Stay updated on the latest Chainlink news