Supposing that contractA is a Fungible Token and contractB is a swapping module that exchanges A for some NFT.
In the above case, user X would call B’s swap() instead of A’s transfer(), and so B would need to call A’s transferfrom() in swap().
I understand how to implement transferfrom/approve to contract A, but not necessarily to implement it by ourselves. (I mean A and B may belong to different teams/orgs.) I am particularly concerned about the USDC case.
So it would be helpful if it is standardized.
So as I see your example, as long as contract A implements CIS2, and the user makes B an operator of their token then it seems that what you need is already possible.
Sorry for my lack of explanation. I know I can achieve something similar to Approve with using Operator, but I’m concerned that an Operator would have the same power as an Address Owner.
So if there is a mistake or malicious intent in the contract B, you could lose the entire amount, right?
Is there any way to check from the user side to see if there is a problem with the contract?
@abizjak
Excuse me for asking again and please let me make sure two questions.
Does USDC follow CIS2 standards without additional features? If a code or standard already in place, it would be greatly appreciated if you could let me know.
When implementing a contract like Dex, where the purpose is to exchange or swap, is it recommended to use operator rather than creating my own approve?
At the time of the design of CIS2 we thought that for a dex-type situation an approach that would have benefits, compared to approvals or operators, is that
user transfers tokens to the swap contract (so that they are owned by it)
swap is made
So at no point is an approval or operator concept needed. Is this something that would make sense in your case?
so in this case, do you mean userX should call A’s transfer(), not B’s swap()?
If I am correct, how does B know how much X transferred and send back tokens in exchange to the user?