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
函数名与合约名称不能重复,如果构造函数的话用以下方式:
function Token(uint256 initialSupply) ==> constructor(uint256 initialSupply)
No visibility specified. Defaulting to "public"
定义函数必须加上public关键字,例如:
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
定义指针需要加关键字storage,例如:
Funder f = funders[_u]; ==> Funder storage f = funders[_u];
Data location must be "memory" for parameter in function, but none was given
函数中的数据位置必须是"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类型的参数不需要加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已经被gasleft()替换了,例如:
uint public _gas ==> gasleft()
"throw" is deprecated in favour of "revert()", "require()" and "assert()". throw
thorw已经不支持了,需要使用require,例如:
if(_to != 0x0){ throw ; } ==> require(_to != address(0x0))
Event invocations have to be prefixed by "emit"
调用事件需要在前面加上emit关键字,例如:
Burn(msg.sender, _value)==>emit Burn(msg.sender, _value)
Operator != not compatible with types address and int_const 0
地址变量不能和0x0进行比较,需要改为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地址类型细分为 address和 address payable,只有 address payable可以使用 transfer(), send()函数,例如:
address public owner ==> address payable public owner
Functions in interfaces must be declared external
接口必须定义为外部函数(回退函数(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
外部函数中的数据位置必须是"calldata",例如:
interface tokenRecipient { function receiveApproval(address _from, bytes _extraData) external; }
==>
interface tokenRecipient { function receiveApproval(address _from, bytes calldata _extraData) external; }