Windows系统下编译智能合约常见的初级错误

相信很多朋友在初学以太坊时会从智能合约的编程开始学起,下面给出了几个在windows系统下编写合约的几个常见问题的解决方法,希望对大家有所帮助(以下问题的测试编译软件为Atom)。

Error1,ParserError: Expected pragma, import directive or contract/interface/library definition.

解决方法:没见过这种情况?别紧张,一般来说这只是你的一个粗心的小错误。你可以看下是不是pragma的合约版本声明那一行末尾少了“;”

Error2,Warning:No visibility specified. Defaulting to "Public"

解决方法:这句话的大意是你未定义合约里的属性或方法的权限,导致“违约公开”。你可以尝试下在函数后面及returns前面添加“public”关键词。(备注:合约属性的权限默认为“internal”,合约方法的权限默认为“public”)

Error3, Warning: Function state mutability can be restricted to pure
  function Hello() public returns (string) {

解决方法:这只是一个警告,一般可以直接跳过进行编译,不过对于安全性能要求高的项目,该类警告需要注意。

参考文献 :

http://liyuechun.org/2017/09/19/how-to-code-smart-contract/

猜你喜欢

转载自blog.csdn.net/weixin_42758350/article/details/81212780