Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it
函數(shù)名與合約名稱(chēng)不能重復(fù),如果構(gòu)造函數(shù)的話(huà)用以下方式:
function Token(uint256 initialSupply) ==> constructor(uint256 initialSupply)
No visibility specified. Defaulting to "public"
定義函數(shù)必須加上public關(guān)鍵字,例如:
function newFunder(address to) returns (uint)
==>
function newFunder(address to) public returns (uint)
Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning
定義指針需要加關(guān)鍵字storage,例如:
Funder f = funders[_u]; ==> Funder storage f = funders[_u];
Data location must be "memory" for parameter in function, but none was given
函數(shù)中的數(shù)據(jù)位置必須是"memory",例如:
function receiveApproval(address _from, bytes _extraData) public;
==>
function receiveApproval(address _from, bytes memory _extraData) public;
Data location can only be specified for array, struct or mapping types, but "memory" was given
array, struct or mapping類(lèi)型的參數(shù)不需要加memory
Invalid type for argument in function call. Invalid implicit conversion from contract TokenERC20 to address requested
使用address(this)替代this,例如:
receiveApproval(msg.sender, _value, this, _extraData);
===>
receiveApproval(msg.sender, _value, address(this), _extraData);
"msg.gas" has been deprecated in favor of "gasleft()" uint public _gas = msg.gas;
msg.gas已經(jīng)被gasleft()替換了,例如:
uint public _gas ==> gasleft()
"throw" is deprecated in favour of "revert()", "require()" and "assert()". throw
thorw已經(jīng)不支持了沫勿,需要使用require,例如:
if(_to != 0x0){ throw ; } ==> require(_to != address(0x0))
Event invocations have to be prefixed by "emit"
調(diào)用事件需要在前面加上emit關(guān)鍵字,例如:
Burn(msg.sender, _value)==>emit Burn(msg.sender, _value)
Operator != not compatible with types address and int_const 0
地址變量不能和0x0進(jìn)行比較,需要改為address(0x0),例如:
require(_to != 0x0) ==> require(_to != address(0x0))
Member "transfer" not found or not visible after argument-dependent lookup in address
solidity 0.5问窃,address地址類(lèi)型細(xì)分為 address和 address payable,只有 address payable可以使用 transfer(), send()函數(shù),例如:
address public owner ==> address payable public owner
Functions in interfaces must be declared external
接口必須定義為外部函數(shù)(回退函數(shù)(fallback function)同理),例如:
interface tokenRecipient { function receiveApproval(address _from, bytes _extraData) public; }
==>
interface tokenRecipient { function receiveApproval(address _from, bytes _extraData) external; }
Data location must be "calldata" for parameter in external function, but none was given
外部函數(shù)中的數(shù)據(jù)位置必須是"calldata",例如:
interface tokenRecipient { function receiveApproval(address _from, bytes _extraData) external; }
==>
interface tokenRecipient { function receiveApproval(address _from, bytes calldata _extraData) external; }