以太坊solidity编程常见错误(不定期更新)

1、报错:
Expected token Semicolon got 'eth_compileSolidity' funtion setFunder(uint _u,uint _amount){
解决:
funtion关键字错了,需要用function;

2、报错:
Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. Funder f = funders[_u]; ^------^
解决:
Funder f,定义指针需要加关键字storage ;修改为Funder storage f = funders[_u];

3、报错:
Invoking events without "emit" prefix is deprecated. e("newFunder",_add,_amount); ^-------------------------^
解决:
调用事件需要在前面加上emit关键字,修改为emit e("newFunder",_add,_amount);

4、报错:
No visibility specified. Defaulting to "public". function newFunder(address _add,uint _amount) returns (uint){ ^ (Relevant source part starts here and spans across multiple lines).
解决:
定义函数必须加上public关键字,修改为function newFunder(address _add,uint _amount) public returns (uint){

5、报错:
"msg.gas" has been deprecated in favor of "gasleft()" uint public _gas = msg.gas; ^-----^

解决: msg.gas已经被gasleft()替换了。修改为uint public _gas = gasleft();

猜你喜欢

转载自blog.csdn.net/haojing8312/article/details/80606226