Solidity Interfaces – Difference Between ERC20.transferFrom and IERC20.transferFrom Explained

erc-20interfacessolidity

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?

Best Answer

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.

Related Topic