Transfer and Approve of ERC20 tokens

Using the Openzeppelin libraries, for example in a function to deposit tokens, I need to check if the contract is approved and the user has the tokens or does the Transfer function take care of that?

1 Like

Yeah, when you deposit tokens, you should approve at first, actually, it should be

token.approve(contract, approvalAmount);

And in the function deposit(), it should call transferFrom().

1 Like

Hi @franco_villa_santana,

You may want to look at the following examples: