Chainlink Local - Documentation
The go-to place for developers who want to learn how to build applications using Chainlink Local
Chainlink Local is an installable dependency. It provides a tool (the Chainlink Local Simulator) that developers import into their Foundry and Hardhat scripts. This tool runs Chainlink CCIP locally which means developers can rapidly explore, prototype and iterate CCIP dApps off-chain, and move to testnet only when they're ready to test in a live environment.
The package exposes a set of smart contracts and scripts with which you build, deploy and execute CCIP token transfers and arbitrary messages on a local Hardhat or Anvil (Foundry) development node. Chainlink Local also supports forked nodes.
User Contracts tested with Chainlink Local can be deployed to test networks without any modifications.
Installation
Install the package by running:
Foundry (git)
forge install smartcontractkit/chainlink-local
and then set remappings to: @chainlink/local/=lib/chainlink-local/
in either remappings.txt
or foundry.toml
file
Hardhat (npm)
npm install @chainlink/local
Remix IDE
import "https://github.com/smartcontractkit/chainlink-local/blob/main/src/ccip/CCIPLocalSimulator.sol";
Usage
Import CCIPLocalSimulator.sol
inside your tests or scripts, for example:
// test/demo.t.sol
pragma solidity ^0.8.19;
import {Test, console2} from "forge-std/Test.sol";
import {IRouterClient, WETH9, LinkToken, BurnMintERC677Helper} from "@chainlink/local/src/ccip/CCIPLocalSimulator/sol";
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();
ccipLocalSimulator.requestLinkFromFaucet(receiver, amount);
}
}
Last updated