A
address sends X
amount of token to B
address. As this transaction happens inside the interface function _transfer(address recipient, uint256 amount)
I know that the amount
variable holds the token number that A
sends to B
.
My question is: does the address
type has a function which let me retrieve amount
after transfer has been called by referring to the transaction address? Not historically, just until the current contract's (contract of one transaction) lifecycle ends.
Based on this question I assume address(this)
returns the contract's own address and can be called with balanceOf
but it won't return a value until I don't call _transfer
. Is it right?
function _transfer(address sender, address recipient, uint256 amount) internal {
uint256 tokenAmountInCurrentContract = amount;
//...
}
function retrieveCurrentContractTokenAmount() internal returns (bool) {
// would this do it?
return balanceOf(address(this));
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}