目前我的visual studio code的solidity默认版本是0.6.4,但truffle用的编译器是0.5.16版本的,用truffle compile报错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、打开扩展的solidity插件的设置
3、点击在settings.json中编辑,末尾添加一句:
"solidity.compileUsingLocalVersion": "latest"
4、终端输入truffle compile,回车,编译成功。