Access to _balance private variable in ERC20 contract when extended


I am trying to extend the _transfer function of the standard erc20 contract. I have imported the erc20 contract and overridden the function like this.

function _transfer(
address sender,
address recipient,
uint256 amount
) isNotBanned internal override(ERC20, ERC20Snapshot) virtual {

I need to access the _balance private variable in the original contract in order for my override to do what I want. As you know, the balances are setup like this in a standard ERC20 contract.

mapping(address => uint256) private _balances;

how can I access the balances in my extended _transfer function? I am receiving a
DeclarationError: Undeclared identifier for _balances when I try to access them.


You can use balanceOf which returns the value of _balance for that user.

If you want to change it entirely then you need to edit the erc20 contract and make it a public variable.