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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

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

發(fā)布時間:2023/12/13 综合教程 26 生活家
生活随笔 收集整理的這篇文章主要介紹了 以太坊solidity编程常见错误(不定期更新) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1、報錯:

Expected token Semicolon got 'eth_compileSolidity' funtion setFunder(uint _u,uint _amount){

解決:

funtion關(guān)鍵字錯了,需要用function;

2、報錯:

Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning. Funder f = funders[_u]; ------

解決:

Funder f,定義指針需要加關(guān)鍵字storage ;修改為Funder storage f = funders[_u];

3、報錯:

Invoking events without "emit" prefix is deprecated. e("newFunder",_add,_amount); -------------------------

解決:

調(diào)用事件需要在前面加上emit關(guān)鍵字,修改為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).

解決:

定義函數(shù)必須加上public關(guān)鍵字,修改為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已經(jīng)被gasleft()替換了。修改為uint public _gas = gasleft();

6、報錯:

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

解決:solidity已經(jīng)不支持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]; ------------

解決:變量重復(fù)定義,變量名和函數(shù)名不能相同。

8、報錯:

error: Function state mutability can be restricted to pure

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

9、報錯:

"sha3" has been deprecated in favour of "keccak256"
解決:sha3已經(jīng)替換為keccak256

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。