Slither工具解决solc版本与当前sol文件版本不兼容的问题

报错提示:Error: Source file requires different compiler version (current compiler is 0.8.9+commit.e5eed63a.Linux.g++) - note that nightly builds are considered to be strictly less than the released version

中文翻译:错误:源文件需要不同的编译器版本(当前编译器为0.8.9+commit.e5eed63a.Linux.g++)-请注意,夜间版本被认为严格低于发布版本

本文使用的是trailofbits/eth-security-toolbox的docker镜像。

拉取安装命令为:

拉取镜像:docker pull trailofbits/eth-security-toolbox

挂载硬盘并运行:docker run -it -v /home/share:/share trailofbits/eth-security-toolbox

查询slither版本:

ethsec@1de8139f5251:~$ slither --version
0.8.3

查找solc命令所在位置:

ethsec@1de8139f5251:~$ find -name solc

./.local/bin/solc

切换到bin目录下

ethsec@1de8139f5251:~$ cd ./.local/bin

查询bin目录下文件,确认文件夹位置

ethsec@1de8139f5251:~/.local/bin$ ls

base58          evmasm    jsonschema          netaddr     slither              slither-check-upgradeability  slither-format  slither-read-storage  solc-select

crytic-compile  flask     manticore           normalizer  slither-check-erc    slither-find-paths            slither-mutate  slither-simil         wasmdump

etheno          futurize  manticore-verifier  pasteurize  slither-check-kspec  slither-flat                  slither-prop    solc                  z3

查询solc-select帮助

ethsec@1de8139f5251:~/.local/bin$ solc-select -h

usage: solc-select [-h] {install,use,versions} ...

positional arguments:

  {install,use,versions}

                        Allows users to install and quickly switch between

                        Solidity compiler versions

    install             list and install available solc versions

    use                 change the version of global solc compiler

    versions            prints out all installed solc versions

optional arguments:

  -h, --help            show this help message and exit

打印所有solc-select版本

ethsec@1de8139f5251:~/.local/bin$ solc-select versions

0.8.9 (current, set by /home/ethsec/.solc-select/global-version)

0.8.8

0.8.7

0.8.6

0.8.5

0.8.4

0.8.3

0.8.2

0.8.13

0.8.12

0.8.11

0.8.10

0.8.1

0.8.0

0.7.6

0.7.5

0.7.4

0.7.3

0.7.2

0.7.1

0.7.0

0.6.9

0.6.8

0.6.7

0.6.6

0.6.5

0.6.4

0.6.3

0.6.2

0.6.12

0.6.11

0.6.10

0.6.1

0.6.0

0.5.9

0.5.8

0.5.7

0.5.6

0.5.5

0.5.4

0.5.3

0.5.2

0.5.17

0.5.16

0.5.15

0.5.14

0.5.13

0.5.12

0.5.11

0.5.10

0.5.1

0.5.0

0.4.9

0.4.8

0.4.7

0.4.6

0.4.5

0.4.4

0.4.3

0.4.26

0.4.25

0.4.24

0.4.23

0.4.22

0.4.21

0.4.20

0.4.2

0.4.19

0.4.18

0.4.17

0.4.16

0.4.15

0.4.14

0.4.13

0.4.12

0.4.11

0.4.10

0.4.1

0.4.0

lc-select use

usage: solc-select use [-h] USE_VERSION

solc-select use: error: the following arguments are required: USE_VERSION

设置solc默认使用版本,例如:

ethsec@1de8139f5251:~/.local/bin$ solc-select use 0.7.1

Switched global version to 0.7.1

最后重新执行检测命令:

如何使用:

批量检测:

slither .

单文件检测:

slither tests/uninitialized.sol

猜你喜欢

转载自blog.csdn.net/redwolf6888/article/details/126400719