How does ERC20Permit reduce approve + transferFrom to a single call?

Hi, I am trying to wrap my head around the ERC20Permit contract. From my understanding of EIP-2612, it reduces the approve + transferFrom calls to a single call. How does ERC20Permit help with this? I still need to call permit + transferFrom if I want to deposit my tokens into a contract. Gas is still spent twice in both cases.

Maybe I am missing something here. A working example with the relevant Web3 signing part would help. Thanks.

2 Likes

Hi, welcome! :wave:

Yeah, just like the EIP2612 you mentioned above, it can be one transaction to let contract get your token, if you want to use this feature, you should write such function permit in your ERC20 Token, and then in another contract, it can be:

function depositToken() public {
  Token.permit(xxx);
  Token.transferFrom(xxx);
}
1 Like

Ah perfect! Now, why didn't I think of that! Thanks very much !!

1 Like