SafeERC20 methods "safeApprove" & "safeTransfer"

Hi OZ team,

I am getting an error when using safeERC20, my smart contract is accepting USDC as payment to buy ERC1155 fractions, but every time I debug the code following the exact same steps from the threads below it is still throwing an error

with safeApprove & safeTransfer error is "transfer exceeds allowance"
with safeIncreaseAllowance and safeTransferFrom error is "transfer exceeds balance"

I don't know what I am doing wrong, so your help will be greatly appreciated.

Note: I'm deploying on Polygon and using
USDC = IERC20(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174);

Thank you in advance.

:computer: Environment

Remix IDE & Truffle

The way approve is used is that the user first needs to call approve on USDC, and then your contract is allowed to transferFrom. You can't call approve for the user because USDC's approve function has no way of knowing that you're authorized, except being called by the user themselves.

If you're specifically using USDC, you can look into permit as an alternative to approve.


Thank you so much Francisco for your response, I sincerely appreciate you answering this silly inquiry as I figured out my mistake after getting away from the code for 24H.

Thanks to you & OZ team for the continuous support & guidance.

1 Like

Glad you figured out. Next time I encourage coming back to share the solution once you find it!

sure I will do it next time