在使用^0.5.10版本的solidity時,若是使用this關鍵字會出現如下問題。app
代碼:ui
require(tokenContract.balanceOf(this) >= _numberOfTokens);(issue is here)
錯誤信息:this
TypeError: Invalid type for argument in function call. Invalid implicit conversion from contract DappTokenSale to address requested. require(tokenContract.balanceOf(this) >= _numberOfTokens);
即提示:code
implicit conversion from contract DappTokenSale to address
使用address(this)替代this。token
require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);(issue is here)