因为下一个项目涉及到 以太坊 合约相关的东西,因此放假的时候需要学习以下 Solidity 相关的东西
刚刚在编译合约的时候出现了以下警告
Warning: Function state mutability can be restricted to pure\n function sayHi() public view returns (string memory _greeting){\n ^ (Relevant source part starts here and spans across multiple lines
修复方法很简单,就是把 public view
改成 public pure
比如我的合约源码如下
pragma solidity ^0.5.8; contract HelloWorldContract { function sayHi() public view returns (string memory _greeting){ _greeting = 'Hello World'; } }
则需要改成
pragma solidity ^0.5.8; contract HelloWorldContract { function sayHi() public pure returns (string memory _greeting){ _greeting = 'Hello World'; } }
目前尚无回复