For my usecase I want to check if msg.value, sent to my smart contract, is actually 10 USDC and not any Shitcoin. Is this done with the approve function of ERC20 interface? Because right now I have this in my .sol File:

require(usdc.approve(msg.sender, msg.value));

1 Answer 1


in most cases there is only one approved USDC contract, so you can easily hard code that for your network inside your own smart contract and not reply on external calls to provide the address unless it's part of your design to do so.

  • So it is impossible that there would be fake USDC or fake USDT as the msg.value? Aug 31, 2021 at 17:50
  • Or better, how do I check if it is USDC and not Ether which is being transfered? Aug 31, 2021 at 18:02
  • msg.value is the amount, it won't have an address in it. there could be fake USDTs, but they are very obvious. token transfers like the one you posted are always for tokens and not ether. ether transfers use different methods. Aug 31, 2021 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.