以太坊開發錯誤答疑,(持續更新)

我會在這篇博客裏持續更新我在開發過程中所遇到的報錯,和解決方案。

1。調用以太坊錢包metamask出現錯誤,Uncaught Error: Invalid number of arguments to Solidity function

答:合約函數調用時應該與聲明參數列表一致,檢查調用合約時輸入的實參是否都對上了。

 

2.合約編譯報錯,TypeError: Type address is not implicitly convertible to expected type address payable

這是因爲0.5.0以上版本新增了 “payable address” 的概念。

address:保存一個20字節的值(以太坊地址的大小)。

payable address:與address相同,但附加轉移和發送。

這種區別背後的想法是,payable address是您可以發送以太幣的地址,而address(普通地址)不能發送以太幣。

聲明方法時,形參要求是payable address類型

下面解決方案代碼

    function TransferEther(address payable _addr,uint256 _value) external onlyOwner{
        _addr.transfer(_value);
    }

google 查到地址轉換實測無效

address payable recharge_address = address(uint160(0x0000000000000000000000000));

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章