mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Document interfaces
This commit is contained in:
parent
cfab70fd89
commit
3f1468142b
@ -922,6 +922,33 @@ Such contracts cannot be compiled (even if they contain implemented functions al
|
|||||||
|
|
||||||
If a contract inherits from an abstract contract and does not implement all non-implemented functions by overriding, it will itself be abstract.
|
If a contract inherits from an abstract contract and does not implement all non-implemented functions by overriding, it will itself be abstract.
|
||||||
|
|
||||||
|
.. index:: ! contract;interface, ! interface contract
|
||||||
|
|
||||||
|
**********
|
||||||
|
Interfaces
|
||||||
|
**********
|
||||||
|
|
||||||
|
Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions:
|
||||||
|
|
||||||
|
#. Cannot inherit other contracts or interfaces.
|
||||||
|
#. Cannot define variables.
|
||||||
|
#. Cannot define structs.
|
||||||
|
|
||||||
|
Some of these restrictions might be lifted in the future.
|
||||||
|
|
||||||
|
Interfaces are basically limited to what the Contract ABI can represent and the conversion between the ABI and
|
||||||
|
an Interface should be possible without any information loss.
|
||||||
|
|
||||||
|
Interfaces are denoted by their own keyword:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
interface Token {
|
||||||
|
function transfer(address recipient, uint amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
Contracts can inherit interfaces as they would inherit other contracts.
|
||||||
|
|
||||||
.. index:: ! library, callcode, delegatecall
|
.. index:: ! library, callcode, delegatecall
|
||||||
|
|
||||||
.. _libraries:
|
.. _libraries:
|
||||||
|
Loading…
Reference in New Issue
Block a user