Q1:compile时遇到错误提示
contracts/Migrations.sol: ParsedContract.sol:7:14: ParserError: Expected identifier, got 'LParen'
constructor() public {
^
Compilation failed. See above.
~/eth-hunt/
初步判断为js的编译器版本不和,即solcjs@x.x.x.,与pragma solidity ^x.x.y 不一样造成,
尝试:
npm uninstall -g truffle
npm install -g truffle
再重复truffle develop ---> compile.问题解决!!!
Q2:compile时提示
Warning: No visibility specified. Defaulting to "public".
function test() pure returns (string) {
^ (Relevant source part starts here and spans across multiple lines).
将contract里的function中的constant 改为 pure public,即可
Q3:调用migrate时不成功遇到Using network 'develop'/n Network up to date.可以试试重新部署 migrate --reset
S1:truffle(develop)> contract = HelloWorld.deployed().then(instance => contract = instance) :instance是参数,()里为函数。
migrate受阻,检查后仍通不过,重新truffle develop >compile > migrate
contract里有pure public console里可以直接 contarct.test(); 调用函数。没有pure只能contarct.test.call(); 调用函数。