We recommend using our template which comes with foundry already setup.

git clone git@github.com:Inco-fhevm/lightning-rod.git
cd lightning-rod
bun install

Using the template, you may want to skip to the cheatcodes reference.

Or setup manually

You do not need to follow these steps if you are using the lightning-rod template.

Follow these steps to add inco to your existing project, or manually setup a new one.

Download the inco libraries

Inco uses npm packages to provide its solidity library.

bun add @inco/lightning @inco/shared

Alternatively, you can use npm/yarn/pnpm.

Setup remappings

Create a file remappings.txt at the root of your contracts directory.

touch remappings.txt

Edit your remappings paths according to your setup.

forge-std/=your/path/to/forge-std/src/
ds-test/=your/path/to/ds-test/src/
@inco/=path/to/your/node_modules/@inco/
@openzeppelin/=path/to/your/node_modules/@openzeppelin/

Due to how solidity imports and remappings work, your remappings have to follow the idiomatic form. Here are the requirements so your project compiles while using inco:

  • left to the = sign, have the following names
    • forge-std/
    • ds-test/
    • @inco/
    • @openzeppelin/
  • right to the = sign, have the path to the corresponding library
    • forge-std/ should point to the src/ directory of your local forge-std library
    • ds-test/ should point to the src/ directory of your local ds-test library
    • @inco/ should point to the @inco directory in your node_modules directory, and not to the @inco/lightning or @inco/shared directories
    • In the same way @openzeppelin/ should point to the @openzeppelin directory in your node_modules directory

To simplify this process, we recommend using bun/npm to import all the dependencies (including foundry-std and ds-test) like so:

bun add  @inco/lightning @inco/shared https://github.com/dapphub/ds-test https://github.com/foundry-rs/forge-std @openzeppelin/contracts

and using this remapping file (supposing that your node_modules sit one directory up from your contracts directory):

@openzeppelin/=../node_modules/@openzeppelin/
forge-std/=../node_modules/forge-std/src/
ds-test/=../node_modules/ds-test/src/
@inco/=../node_modules/@inco/