
目前我的visual studio code的solidity默認(rèn)版本是0.6.4,但truffle用的編譯器是0.5.16版本的,用truffle compile報(bào)錯(cuò)Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.6.4".。
解決方法:
1、把sol改為
pragma?solidity?^0.5.16;
2、打開擴(kuò)展的solidity插件的設(shè)置



3、點(diǎn)擊在settings.json中編輯,末尾添加一句:
????"solidity.compileUsingLocalVersion":?"latest"
4、終端輸入truffle compile,回車,編譯成功。