Sorry guys, I have to do an interaction between two smart contracts:
In the first there is the balanceOf function
In the second there is a function that takes _value as parameter
I need to check that the caller (msg.sender) of a function in the second contract has tokens at least equal to _value
My question is whether this statement makes sense: require (_value == ContractToken.balanceOf (address (msg.sender))
ContractToken would be the call of the contract containing the token.
Nov 19, 2021, 5:10 PM
Thanks in advance
Nov 19, 2021, 5:13 PM
if it's "atleast" equal to value, you should use <= comparator instead. also you can directly pass msg.sender instead address (msg.sender) since msg.sender is an address
Nov 19, 2021, 5:15 PM
Thank you so much
Yes u have right, i should use <= my fault
i got it <3
Thanks i'll try it then
Nov 19, 2021, 5:17 PM
msg.sender.balance represents the native coin balance like ethers, tokenContract.balanceOf should be the way to get the token balance
Nov 19, 2021, 5:20 PM
Ok, i understand
Nov 19, 2021, 5:21 PM