IERC20
vs ERC20
#2586
-
I am bit confused about them. As i understand But with the help of
So what makes them different to each other? And How do we know what Contract to use? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Hey @MasterofBlockchain |
Beta Was this translation helpful? Give feedback.
-
Context on Interfaces (understand these rules): As the functions implemented must be declared E.g. Let's assume we have Contract A, B, C and Interface Z. A, B and C have a common function (literally the same) and therefore, will be redundant. It is much easier, cleaner (concise) and modular to implement that common function in Z, and then letting A, B and C inherit Z to use that common function. Another simple analogy is we do not have to know what is going on, and can just implement the functionality ("turns the light on") it provides. Good read: https://medium.com/coinmonks/solidity-tutorial-all-about-interfaces-f547d2869499 |
Beta Was this translation helpful? Give feedback.
Context on Interfaces (understand these rules):
As the functions implemented must be declared
external
, they are primarily used in other contracts because implementing functions manually in every other contract is redundant when you can just use a common interface.E.g. Let's assume we have Contract A, B, C and Interface Z. A, B and C have a common function (literally the same) and therefore, will be redundant. It is much easier, cleaner (concise) and modular to implement that common function in Z, and then letting A, B and C inherit Z to use that common function.
Another simple analogy is
we do not have to know what is going on, and can just implement the functionality ("turns the ligh…