Table of Contents
概述
开发以太坊智能合约,本地编译时,如果本地的 solidity 编译器 solc 的版本与合约代码使用的版本不一致时,编译会失败。
比如说合约使用 0.5.16 版本,而编译器使用 0.7.4 版本。
编译的时候会报以下错误:
Error: Source file requires different compiler version (current compiler is 0.7.4+commit.3f05b770.Linux.g++) - note that nightly builds are considered to be strictly less than the released version
--> StakingRewards.sol:5:1:
|
5 | pragma solidity ^0.5.16;
| ^^^^^^^^^^^^^^^^^^^^^^^^
但是如果你把 0.7.4 版本卸载,安装 0.5.16 版本,下次调试其他版本合约怎么办?难道又要卸载重装?显然不是一个解决办法。
所以我们需要一个 solc 的版本管理工具,可用安装多个 solc 版本,然后选择一个使用,随时可以切换,原理类似于 Java 的版本管理工具 jenv 和 nodejs 的版本管理工具 nvm。
经过一番对比,我觉得 solc-select 好用,下面做简单介绍。
安装
安装的时候会下载所有稳定版本,solc 应该也不大, 安装很快。
Linux
git clone https://github.com/crytic/solc-select.git
./solc-select/scripts/install.sh
脚本运行完后将 .solc-select 加入 PATH 中, 需要将以下语句加入 .bashrc 或者 .zshrc 文件末尾。
export PATH=$HOME/.solc-select:$PATH
然后 source rc 文件。
source ~/.zshrc
OS X (测试失败)
osx 我根据官网的安装指引,安装失败了(20201111 号测试),已提了issue 。
目前 commit id: 002b9a8be26533c2240e1265870449f629477e32
有兴趣自己试下。
docker pull trailofbits/solc-select
docker run --read-only -i --rm --entrypoint='/bin/sh' trailofbits/solc-select:latest -c 'cat /usr/bin/install.sh' | bash -e
验证安装
首先检查是否在 PATH 中
$ which solc
/home/shiming/.solc-select/solc
运行 solc --versions,查看可用的版本,出现版本列表就安装成功了
$ solc --versions
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
......
查看目前所用的版本
$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.0+commit.acd334c9.Linux.g++
切换版本
$ solc use 0.5.16
Now using version 0.5.16
切换到正确的版本就可以愉快的编译了!
升级
$ solc --upgrade




您好,我按您的步骤从linux系统上做了好几遍,每次做完都是输入which solc有显示,但是输入solc–version没有任何显示,请问可以加您个联系方式吗,我想把我做的的截图给您看一下,您看看是不是我中间步骤有什么问题,非常感谢!下面是我的邮箱。
您好 请问您是怎么解决这个问题的
我在运行./solc-select/scripts/install.sh的时候出现下面的问题,
Installing solc versions into /home/zxy/.solc-select/usr/bin
./install_solc.sh: line 81: curl: command not found
您好,请问您知道搜这是哪里出了问题吗
我也是这个问题。而且打开了那个文件之后,根本没有install.sh的文件
去github看官方最新文档,mac应该早就支持了
问题解决了,谢谢!
Thank you!!1
Our AI-powered traffic solution delivers engaged, keyword-specific visitors from your target locations, saving you money compared to expensive paid ad platforms. Contact us today.
https://marketingaged.com/
What if liushiming.cn could tap into TikTok for genuine leads? Our AI-driven growth service zeros in on the ideal users—based on hashtags they use and accounts they follow—to boost your reach and send traffic back to you. We’ve had websites like yours see 100+ new leads in a month.
Want to make TikTok work for liushiming.cn? Watch this short video for more info: https://www.youtube.com/shorts/sfVup2NhPQ4
What if liushiming.cn could leverage TikTok for genuine leads? Our AI-driven growth service targets the right users—based on hashtags they use and people they watch—to supercharge your reach and push traffic back to you. We’ve had similar websites see 100+ leads in 30 days.
Ready to make TikTok work for liushiming.cn? Get more information here: https://boostgrow.co/
Ever thought how liushiming.cn could tap into TikTok for real leads? Our smart AI growth service targets the perfect users—based on hashtags they use and accounts they follow—to skyrocket your reach and drive traffic back to you. We’ve had websites like yours see over 100 leads monthly.
Ready to make TikTok work for liushiming.cn? Get more information here: https://boostgrow.co/
Grow your website traffic with our AI-powered service, delivering targeted visitors at a fraction of the cost of paid ads. Contact us to start growing your audience.
https://ow.ly/iuvu50XSIHi
Your article helped me a lot, is there any more related content? Thanks!
Hi there,
Here is the greatest results Video generator for eCommerce websites like liushiming.cn.
Letstok helps store owners create videos without effort.
Paste your product link → get a real-person video ad.
Perfect for eCommerce teams short on time and budget.
Try it free this Black Friday (50% off): https://bit.ly/LetstokAI
Best,
Tristan Balfour
Letstock AI
Struggling with low website leads for liushiming.cn? This short video shows how our AI can boost your traffic: https://www.youtube.com/shorts/iojvp6ZtjW4
Hope you’re well,
I noticed your business online and wanted to pass this along.
Here’s a free service that can help you push your site out wider across multiple classified sites with no manual posting.
If you want to push your site out wider, here’s the address:
http://www.websubmitterpro.com
It’s a free traffic booster and takes less effort than posting manually.
If you want more free traffic tools, let me know.
Boost your liushiming.cn website’s traffic with AI! Watch this to learn more: https://www.youtube.com/shorts/iojvp6ZtjW4
Struggling with low website leads for Liushiming Cn? This short video shows how our AI can boost your traffic: https://www.youtube.com/shorts/iojvp6ZtjW4
Attract the right audience to your site with our AI-driven traffic solution, offering better results than paid ads at a fraction of the price. Get started today.
https://marketingaged.com/
Ready to drive targeted visitors to your liushiming.cn site? This quick video explains how our AI works: https://www.youtube.com/shorts/iojvp6ZtjW4
Not getting enough leads for liushiming.cn? Check out this video to see our AI traffic solution in action: https://www.youtube.com/shorts/iojvp6ZtjW4
Hey,
Quick one — I came across a product that’s converting insanely well right now: O2 Cool Mist.
It’s one of those “easy wins” — high demand + simple angle (comfort, cooling, daily use).
If you already have traffic, this could turn into a steady extra income stream without changing your setup.
Want me to show you how to plug it into your site in minutes?
click Here for more : https://sites.google.com/view/openclawmastered/home?authuser=3
Want more targeted traffic to your liushiming.cn website? See how our AI-powered solution can help in this quick video: https://www.youtube.com/shorts/rTwcDCntnYg
Unlock more targeted leads with our AI! Watch this short video to get started: https://www.youtube.com/shorts/rTwcDCntnYg
Hi,
Delay makes the AI gap harder to close
Most businesses still think AI is a future upgrade.
That is the wrong read.
AI is already becoming an operational advantage.
Every month businesses delay AI adoption, competitors collect:
• More real customer questions and interaction data
• Better systems for answering without delay
• Sharper lead qualification
• More efficient support
• More visitors turning into leads, bookings, and buyers
The advantage builds on itself.
Fast.
This is the same pattern we saw with:
• Businesses that adapted early to mobile
• E-commerce
• Organic search
• Social media marketing
The early movers gained leverage. The late movers paid more to catch up.
This AI shift is larger because it changes how customers interact with the business itself.
Companies adding conversational AI now are creating advantages that get harder to match later.
See it in action: https://theollehai.com
Regards,
— Trey Symonds
Olleh AI
In case you wish to stop getting any more emails from this message, feel free to fill the form at bit. ly/fillunsubform with your domain address (URL).
80 George Street, Avon, CA, USA, 91347
Watch this if you are struggling to get targeted leads to your Liushiming Cn website: https://www.youtube.com/shorts/rTwcDCntnYg
Watch this if you are struggling to get targeted leads to your liushiming.cn website: https://www.youtube.com/shorts/rTwcDCntnYg
Not getting enough leads for Liushiming Cn? Check out this video to see our AI traffic solution in action: https://www.youtube.com/shorts/rTwcDCntnYg
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.bh/ar-BH/register-person?ref=S5H7X3LP
Our AI-optimized traffic solution sends engaged, keyword-specific visitors to your site for less than traditional paid ads. Learn more to grow your business.
https://marketingaged.com/