Interface in Solidity
Thanks to Alim.
Code
We firstly deploy counter contract
Now deploy MyContract contract
You click the increment and then count button in counter contract
Now copy the counter contract’s address, in this sample, 0XAE0…
and paste the incrementCounter button in MyContract contract.
Click it.
You can check the count situation in counter contract.
This is interface business.
ERC20 | IERC20
What does really Interface make Interface….
The main point of using interfaces ( or Abstract Contracts ) is to provide a customizable and re-usable approach for your contracts.
ERC20
is an implementation of the Interface defined in IERC20
.
IERC20
defines function signatures without specifying behavior; the function names, inputs and outputs, but no process.
ERC20
inherits this Interface and is required to implement all the functions described or else the contract will not deploy.
If this is deployed, then we can safely say that all the functions described in the ERC20 Interface laid out in IERC20
have corresponding implementations in ERC20
.
Look at IERC20 Interface :
Now look at ERC20
ERC20 inherits the IERC20 Interface
Do you want to see both of them in one picture ?
Come on
This is ERC20 an IERC20 business