日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2024/6/30 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 以太坊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();

6、報錯:

"throw" is deprecated in favour of "revert()", "require()" and "assert()". throw ;

解決:solidity已經不支持thorw了,需要使用require,用法require()

throw 寫法:

if(msg.sender !=chairperson ||voters[_voter].voted ){

throw ;

}

require寫法:

require(msg.sender !=chairperson ||voters[_voter].voted);

7、報錯:

This declaration shadows an existing declaration. Voter delegate = voters[to]; ^------------^

解決:變量重復定義,變量名和函數名不能相同。

8、報錯:

error: Function state mutability can be restricted to pure

解決:以前版本是可以不指定類型internal pure(外部不可調用),public pure(外部可調用)(如不指定表示函數為可變行,需要限制)

9、報錯:

"sha3" has been deprecated in favour of "keccak256"
解決:sha3已經替換為keccak256

轉載于:https://www.cnblogs.com/xiaocongcong888/p/9432155.html

總結

以上是生活随笔為你收集整理的以太坊solidity编程常见错误(不定期更新)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。