usage of this.
Example
Using
this
to call functions in the same contract makes the call an external call.That means an extra 2100 gas, and rewriting the
msg.*
variables.better off not using
this.*
until you find the very few use cases.
Note if you drop this
:
this
:require(
balanceOf
(msg.sender) >= amount, "Not Enough WRings to unwrap"
it will not work
That is because balanceOf
is external, to stop developers using suboptimal (in terms of gas) patterns.
since the contract inherits ERC20,
balanceOf
is native to itself; contract cannot call its own external function,
Solution:
You should access the _balanceOf
mapping instead. It is internal
Last updated