vscode编译智能合约版本报错note that nightly builds are considered to be strictly less than thereleased version

项目场景

将智能合约sol文件放入到vscode时出现报错,智能合约的开发、编译和部署


问题描述

vscode在编译智能合约时,第一行为pragma solidity ^0.8.20,出现报错:

Source file requires different compiler version (current compiler is 0.8.19+commit.7dd6d404.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
在这里插入图片描述


原因分析

在编译智能合约时遇到了与 Solidity 版本相关的错误,例如 pragma solidity ^0.8.20 报错,通常有几种可能的原因和解决方法:

  1. Solidity 版本问题:检查你的 Solidity 编译器版本是否支持 ^0.8.20。如果你使用的是旧版本的编译器,你可能需要升级到支持此版本的编译器。
    因为vscode捆绑了自己的 solidity 编译器(这是最新的),而且大多数教程都使用旧版本的语言。也就是vscode里的插件自动选择了0.8.19版本的编译器,而0.8.19以上的版本号,并没有这个编译器的版本,在vscode插件市场里搜索solidity,就是下面这个插件下载的时候自动绑定了0.8.19
    在这里插入图片描述
  2. 编译器配置问题:确保你的编译器配置正确。有时候,编译器可能会在配置文件中指定要使用的版本。检查配置文件(如 truffle.jshardhat.config.js)并确保 Solidity 版本与你的合约版本匹配。

解决方案

在sol文件里右击鼠标,然后点击Solidity: Download compiler and set workspace local Path,即可下载该版本的编译器并且设置到这个当前地址
在这里插入图片描述
到solidity插件主页,点击扩展设置
在这里插入图片描述
搜索default compiler,选择到localFile,再重启vscode即可解决这个bug问题
在这里插入图片描述

小结

希望本文能够帮助读者解决这个编译版本的问题,如果有任何疑问,欢迎留言讨论🌹

  • 33
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 22
    评论
It seems that you are experiencing an error related to the requirement "tb-nightly==2.9.0". This error message indicates that the specified version of the "tb-nightly" package could not be found or installed. There could be a few reasons for this error: 1. Outdated package: The version "2.9.0" of tb-nightly might not be available anymore or may have been renamed or deprecated. Try checking for the latest version of tb-nightly or consider using a different package. 2. Dependency conflict: The specified version of tb-nightly might have conflicting dependencies with other packages in your Python environment. In such cases, you can try upgrading or downgrading other packages to resolve the conflict. To troubleshoot this issue, you can try the following steps: 1. Update pip: Run the following command to update pip to the latest version: ``` pip install --upgrade pip ``` 2. Check package availability: Make sure that the "tb-nightly" package is still maintained and available. You can search for it on the Python Package Index (PyPI) website or use the `pip search` command to check if it exists. 3. Use a different version: If the specific version is not critical, you can try installing a different version of tb-nightly by omitting the version specifier. For example: ``` pip install tb-nightly ``` 4. Resolve dependency conflicts: If there are conflicting dependencies, you might need to manually install compatible versions or consider using a virtual environment tool like `venv` or `conda` to isolate your Python environment. Remember to ensure that your Python environment is properly set up and there are no restrictions or limitations imposed by your system or network configurations.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值