|
1 | 1 | # Chainlink CCIP Smart Contracts
|
2 | 2 |
|
| 3 | +> [!IMPORTANT] |
| 4 | +> Since v1.6.0 of the CCIP contracts, the contracts have been moved to a new repository: |
| 5 | +> [chainlink-ccip](https://github.com/smartcontractkit/chainlink-ccip). |
| 6 | +> The EVM contracts exist in the `chains/evm` directory of the repository. |
| 7 | +
|
3 | 8 | ## Installation
|
4 | 9 |
|
| 10 | +Chainlink-ccip relies on chainlink-evm, below are the instructions to install both. |
| 11 | +To find the correct version of chainlink-evm to use for any given version of chainlink-ccip, |
| 12 | +please refer to the `package.json` file in `/chains/evm`. |
| 13 | +It contains an NPM dependency on `@chainlink/contracts-evm` with the correct version for the given version of chainlink-ccip. |
| 14 | + |
| 15 | +NOTE: while other versions of chainlink-evm may work, we only test against the version specified in the `package.json` file. |
| 16 | +Audits are also only done against the version specified in the `package.json` file. |
| 17 | +No guarantees are made for other versions. |
| 18 | + |
| 19 | +#### Foundry (git) |
| 20 | + |
| 21 | +> [!WARNING] |
| 22 | +> When installing via git, the ref defaults to master when no tag is given. |
| 23 | +
|
| 24 | +When installing through git, it is recommended to use a specific version tag to avoid breaking changes. |
| 25 | +The corresponding git tag will be `contracts-ccip/v<version>` for chainlink-ccip, |
| 26 | +and `contracts/v<version>` for chainlink-evm. |
| 27 | + |
| 28 | +```sh |
| 29 | +$ forge install smartcontractkit/chainlink-evm@<version_tag> |
| 30 | +$ forge install smartcontractkit/chainlink-ccip@<version_tag> |
| 31 | +``` |
| 32 | + |
| 33 | +Add the following remappings |
| 34 | + |
| 35 | +``` |
| 36 | +@chainlink/contracts/=lib/smartcontractkit/chainlink-evm/contracts/ |
| 37 | +@chainlink/contracts-ccip/contracts/=lib/smartcontractkit/chainlink-ccip/chains/evm/contracts/ |
| 38 | +``` |
| 39 | +#### NPM |
| 40 | + |
5 | 41 | ```sh
|
6 |
| -# via pnpm |
| 42 | +# pnpm |
| 43 | +$ pnpm add @chainlink/contracts-evm |
7 | 44 | $ pnpm add @chainlink/contracts-ccip
|
8 |
| -# via npm |
| 45 | +``` |
| 46 | +```sh |
| 47 | +# npm |
| 48 | +$ npm install @chainlink/contracts-evm --save |
9 | 49 | $ npm install @chainlink/contracts-ccip --save
|
10 | 50 | ```
|
11 | 51 |
|
| 52 | +Add the following remappings |
| 53 | + |
| 54 | +``` |
| 55 | +@chainlink/contracts/=node_modules/@chainlink/contracts/ |
| 56 | +@chainlink/contracts-ccip/contracts/=node_modules/@chainlink/contracts-ccip/contracts/ |
| 57 | +``` |
| 58 | + |
12 | 59 | ### Directory Structure
|
13 | 60 |
|
14 | 61 | ```sh
|
15 | 62 | @chainlink/contracts-ccip
|
16 | 63 | ├── contracts # Solidity contracts
|
| 64 | +├── scripts # Compilation script |
17 | 65 | └── abi # ABI json output
|
18 | 66 | ```
|
19 | 67 |
|
20 | 68 | ### Usage
|
21 | 69 |
|
22 |
| -The solidity smart contracts themselves can be imported via the `contracts` directory of `@chainlink/contracts-ccip`: |
| 70 | +> [!WARNING] |
| 71 | +> Contracts in `dev/` directories or with a typeAndVersion ending in `-dev` are under active development |
| 72 | +> and are likely unaudited. |
| 73 | +> Please refrain from using these in production applications. |
| 74 | +
|
| 75 | + |
| 76 | +The contracts can be imported via `@chainlink/contracts-ccip/contracts`: |
23 | 77 |
|
24 | 78 | ```solidity
|
25 |
| -import '@chainlink/contracts-ccip/contracts/applications/CCIPReceiver.sol'; |
| 79 | +import {CCIPReceiver} from '@chainlink/contracts-ccip/contracts/applications/CCIPReceiver.sol'; |
26 | 80 | ```
|
27 | 81 |
|
| 82 | +#### Getting started with CCIP |
| 83 | + |
| 84 | +To get started with CCIP, please refer to the [CCIP documentation](https://docs.chain.link/ccip). |
| 85 | + |
| 86 | +The MockRouter contract is a good starting point when developing dapps that use CCIP. |
| 87 | +It is a simplified same-chain entry and exit point for CCIP messages. |
| 88 | +It lives in `contracts/test/mocks/MockRouter.sol`. |
| 89 | + |
| 90 | + |
28 | 91 | ### Remapping
|
29 | 92 |
|
30 |
| -This repository uses [Solidity remappings](https://docs.soliditylang.org/en/v0.8.20/using-the-compiler.html#compiler-remapping) to resolve imports. |
31 |
| -The remapping is defined in the `remappings.txt` file. |
| 93 | +This repository uses [Solidity remappings](https://docs.soliditylang.org/en/v0.8.20/using-the-compiler.html#compiler-remapping) to resolve imports, |
| 94 | +which are defined in the `remappings.txt` file. |
| 95 | + |
| 96 | +Please see the Installation section above for the correct remappings based on your installation method. |
| 97 | + |
| 98 | +If required, you can remap dependencies used within CCIP contracts, e.g. Openzeppelin contracts, |
| 99 | +by adding the following to your `remappings.txt` file: |
| 100 | + |
| 101 | +``` |
| 102 | +@chainlink/contracts/src/v0.8/vendor/openzeppelin-solidity/v4.8.3/contracts/=node_modules/@openzeppelin/contracts/ |
| 103 | +@chainlink/contracts/src/v0.8/vendor/openzeppelin-solidity/v5.0.2/contracts/=node_modules/@openzeppelin/contracts/ |
| 104 | +``` |
| 105 | + |
| 106 | +This allows you to use a wide range of versions of Openzeppelin in your project without conflicts. |
32 | 107 |
|
33 | 108 | ### Changesets
|
34 | 109 |
|
|
0 commit comments