Can someone explain to me about this error? I just tried override feature in Solidity v0.6, but I got error Expected '{' but got reserved keyword 'override' function totalSupply() public override view returns (uint256)
when compile contract.
pragma solidity >=0.4.21 <0.7.0;
import "./IERC20.sol";
contract ERC20 is IERC20 {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public override view returns (uint256) {
return _totalSupply;
}
}
Interface contract
pragma solidity >=0.4.21 <0.7.0;
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
}
totalSupply
in interfaceIERC20
asvirtual
. – goodvibration Apr 22 '20 at 10:24external
instead ofpublic
. – goodvibration Apr 22 '20 at 10:25