NodeJS Slither未导入所需文件

brjng4g3  于 2023-08-04  发布在  Node.js
关注(0)|答案(1)|浏览(106)

我有一个智能合约叫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进行任何配置吗?
我得到了excly我所期望的,我把一个描述和代码,并得到了我所寻找的

bejyjqdl

bejyjqdl1#

当使用slither分析Party.sol智能合约时遇到错误时,必须验证IERC721.sol文件是否位于相对于Party.sol的正确目录中。
仔细检查import语句的相对路径也是至关重要的,因为../tokens/IERC721.sol建议IERC721.sol文件应该位于Party.sol位置上一级的目录中。
如果需要,请考虑使用完整的绝对路径或配置slither以包含“tokens”目录的正确路径。
如果错误仍然存在,那么浏览crytic-compile库文档以获得关于编译契约的更多见解可能会有所帮助。

相关问题