我有一个名为 Party.sol 的智能合约
pragma solidity 0.8.17;
import "../tokens/IERC721.sol";
import "./PartyGovernanceNFT.sol";
import "./PartyGovernance.sol";
我正在尝试使用 slither 提取调用图:
slither Party.sol --print call-graph
我收到此错误:
crytic_compile.platform.exceptions.InvalidCompilation: Invalid solc compilation Error: Source "tokens/IERC721.sol" not found: File not found. Searched the following locations: "".
--> Party.sol:4:1:
|
| import "../tokens/IERC721.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
我需要对编译器或滑行器进行任何配置才能正确读取导入吗?
我得到了我所期望的,我输入了描述和代码,并得到了我想要的东西
所以我想我在 slither -> README.md FAQ 部分找到了您问题的解决方案。
简短的摘录:
How do I fix "unknown file" or compilation issues?
Because slither requires the solc AST, it must have all dependencies available.
If a contract has dependencies, slither contract.sol will fail.
Instead, use slither . in the parent directory of contracts/ (you should see contracts/ when you run ls)....
您应该尝试从作为合约及其依赖项的父目录的路径运行命令。所以如果文件夹结构看起来像这样
- src <- this is the path from which you should run "slither ./contracts/Test.sol"
- contracts
- Test.sol
- tokens
- Dependency.sol
...more folders
如果 Test.sol 具有 Dependency.sol 导入,并且您在“contracts”文件夹中运行该命令,则会失败。到目前为止,除了从更父路径运行命令之外,我无法找到解决方案。
祝你好运!