First question : I am importing the ERC20.sol OZ smart contract and I noticed on this forum that the common practice regarding the _beforeTokenTransfer function is:
- Taking ERC20.sol as a parent contract from which my own contract inherit.
- Overriding this _beforeTokenTransfer function from my child contract if I want to add some action before each token _transfer.
I understand therefore that the _transfer function in the ERC20 parent contract, once called, is also calling the _beforeTokenTransfer function in the child contract. Is that not an issue, meaning a parent contract function calling a child contract function ? Overriding means totally replacing a parent function from the child contract, not taking into account the inheritance situation ?
Second question : if I put a _beforeTokenTransfer function in my child contract overriding the ERC20 parent function, can I also call from the child function another function in my child contract ? Meaning :
- I implement the overriding _beforeTokenTransfer function in my child contract
- This overriding function, once called from the _transfer function in the ERC20 parent contract, can call during its execution another function in the child contract.
Thanks in advance.