ERC20Capped
inherits from ERC20Mintable
, which inherits from ERC20
.
So if you inherit from ERC20Capped
, then you don't need to inherit from ERC20
.
Therefore (though without verifying it via compilation), I'm pretty sure that you can do:
contract SimpleToken is ERC20Detailed, ERC20Capped {
uint8 public constant DECIMALS = 18;
constructor (uint256 cap)
ERC20Detailed("SimpleToken", "SIM", DECIMALS)
ERC20Capped(cap)
public {
...
}
}
It is a compatibility layer for ERC20 tokens deployed before the standard was finalized.
In the final specification function should throw in case of an error.
For transfer
it says
[..] The function SHOULD throw if the message caller’s account balance does not have enough tokens to spend.
The two problems the function try to fix are:
- Tokens returning false instead of throwing.
- Early draft token define
transfer
return nothing. This clash wit newer solc version that requires the function to return a bool.
Best Answer
Those two lines do not perform an arithmetic operation, so moving them inside the
unchecked
block doesn't provide any benefit. Perhaps it will make the code a little harder to read: