Using safeTransferFrom, is there any benefit of checking allowance before performing the safeTransferFrom?
Just with the safeTransferFrom it would revert is there is not enough allowance, right?
So can I remove the allowance check and save gas? Or is there a good reason to keep it?
If missing allowance, just revert, as stated in the require.
AFAIK safeTransferFrom also would revert if no allowance, since the transferfrom wouldn't succeed. Since there is no specific operation other than revert, is there a point on performing the check of allowance? Or could I just ignore the first line as it doesn't add any value/security?
I don't know if I understand you, but the require here has nothing to do with under/overflow. But rather with checking if there is enough allowance before a safeTransferFrom, and know if it is useful at all.
It does. Not having enough allowance would cause a revertinstead, assuming no other checks. This returns error 0x000...000011, which is kind of cryptic. When using a require, there is a clear error message
correct. In the OZ implementations the common pattern is to find a require and then an unchecked block to optimize for gas. You don't seem to be implementing a token, by your first example. It seems that you are interacting with a token. two different things
that's right. if you are calling a token there is no risk in not checking. it just means that you might get an error message or an error code depending on the token implementation instead of a consistent error message