Make balanceOf virtual in ERC20

Can we make balaceOf() virtual in ERC20.sol ?

There are cases when the balance is changing over time, and to save costs for transactions you can implement the changed balance dynamically. This usually occurs in DeFi when users are getting interests, or there may be cases when the token holders are awarded extra tokens.

I have seen this implementation in aave: https://github.com/aave/aave-protocol/blob/f7ef52000af2964046857da7e5fe01894a51f2ab/contracts/tokenization/AToken.sol#L338

But they are using an older version of OpenZeppelin to override the balanceOf

1 Like

I think you can add your case at here:

1 Like

Hi @drbullock,

Welcome to the community :wave:

As @skyge said, if you can add your use case, that would be appreciated.