Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remapping Troubleshooting FAQ to README #2236

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,22 @@ If you have a `node_modules/` folder, it must be in the same directory as `contr
run the compilation command for the framework you are using e.g `npx hardhat compile`. That must work successfully;
otherwise, slither's compilation engine, crytic-compile, cannot generate the AST.

* If `node_modules/` is not in the `contracts/` directory of your project, you may need to use **remappings**. If a project has dependencies such as OpenZeppelin and you want to run Slither on a single `.sol` file, add the remapping on the command line e.g. `--solc-remaps @=node_modules/@` or to the `slither.config.json` in your project's root. Note, this should not be required for Foundry projects as it is handled automatically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foundry projects also require remappings if you want to analyze a specific .sol file that requires imports. Read more here: Foundry Static Analysis Docs.

I'm not sure this is accurate as of the 0.10.0 release. We use Foundry (which automatically configures the remappings) to compile single files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the last bit ("... or use a slither tool like slither-check-erc...") is accurate either. You can run both slither and tools like slither-check-erc with a project directory (like .) as target and not worry about remappings; in the case of standalone tools, they take the contract name you want to analyze:

% slither-check-erc .  Counter
# Check Counter

## Check functions
[ ] totalSupply() is missing 
[ ] balanceOf(address) is missing 
[ ] transfer(address,uint256) is missing 
[ ] transferFrom(address,address,uint256) is missing
...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elopez is correct my mistake, slither-check-erc . Counter does work without any remappings.

slither.config.json:

```json
{
"solc_remaps": "@=node_modules/@"
}
```

Explicit example using hardhat:

```bash
slither contracts/MemeCoin.sol --solc-remaps @=node_modules/@
```

## License

Slither is licensed and distributed under the AGPLv3 license. [Contact us](mailto:opensource@trailofbits.com) if you're looking for an exception to the terms.
Expand Down