An open API service indexing awesome lists of open source software.

https://github.com/smartcontractkit/chainlink-local

The Chainlink CCIP Local Simulator, visit documentation by clicking the link below:
https://github.com/smartcontractkit/chainlink-local

chainlink

Last synced: 2 months ago
JSON representation

The Chainlink CCIP Local Simulator, visit documentation by clicking the link below:

Awesome Lists containing this project

README

        

## Chainlink Local

Chainlink Local is an installable dependency. It provides a tool (the Chainlink Local Simulator) that developers import into their Foundry or Hardhat or Remix projects. This tool runs [Chainlink CCIP](https://docs.chain.link/ccip) locally which means developers can rapidly explore, prototype and iterate CCIP dApps off-chain in a local environment, 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 Remix, 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 (assuming network specific contract addresses such as Router contracts and LINK token addresses are passed in via a constructor).

To view more detailed documentation and more examples, visit the [Chainlink Local Documentation](https://docs.chain.link/chainlink-local).



Watch the demo on YouTube

### 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

#### Foundry (soldeer)

```
forge soldeer install chainlink-local~v0.2.4-beta https://github.com/smartcontractkit/chainlink-local.git
```
Replace `v0.2.4-beta` with your desired version number.

#### Hardhat (npm)

```
npm install @chainlink/local
```

#### Remix IDE

```solidity
import "https://github.com/smartcontractkit/chainlink-local/blob/main/src/ccip/CCIPLocalSimulator.sol";
```

Once you have installed CCIP Local, you are now ready to start using it with your project.

### Usage

Import `CCIPLocalSimulator.sol` inside your tests or scripts, for example:

```solidity
// 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);
}

}
```

### Learn more

To view detailed documentation and more examples, visit the [Chainlink Local Documentation](https://docs.chain.link/chainlink-local).

> **Note**
>
> _This tutorial represents an educational example to use a Chainlink system, product, or service and is provided to demonstrate how to interact with Chainlink’s systems, products, and services to integrate them into your own. This template is provided “AS IS” and “AS AVAILABLE” without warranties of any kind, it has not been audited, and it may be missing key checks or error handling to make the usage of the system, product or service more clear. Do not use the code in this example in a production environment without completing your own audits and application of best practices. Neither Chainlink Labs, the Chainlink Foundation, nor Chainlink node operators are responsible for unintended outputs that are generated due to errors in code._