1

Calling ether of these in my contract does the same thing. What is the difference then?

ERC20(tokenAddress).transferFrom(msg.sender, address(this), amount);

IERC20(tokenAddress).transferFrom(msg.sender, address(this), amount);

I thought IERC20 was just the interface so I would have to implement the function myself. But both transfer the token between addresses.

Could I have a caching problem, or do they actually do the same thing?

1 Answer 1

1

They're effective the same thing in this case.

But what ERC20 does that's different from IERC20 is that it's importing the entire contract API, as opposed to the public bits.

When you're using IERC20, there's zero chance you'll accidentally tie into custom functionality. That's why it's better. you're aiming for a smaller interface, so it keeps the design cleaner.

Your Answer

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

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