diff options
author | chriseth <chris@ethereum.org> | 2019-01-08 07:05:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-08 07:05:24 +0800 |
commit | 44de865da1fddc8678f250b55440810c9981dd22 (patch) | |
tree | e97c5635b0c17f949b4d6a8c2ceaef574405c738 /docs | |
parent | cfa119889224e6d6c9641dafe3099d90de7e4051 (diff) | |
parent | cc99d636650d20a35a446d16f2b81d1fa8a2dabd (diff) | |
download | dexon-solidity-44de865da1fddc8678f250b55440810c9981dd22.tar.gz dexon-solidity-44de865da1fddc8678f250b55440810c9981dd22.tar.zst dexon-solidity-44de865da1fddc8678f250b55440810c9981dd22.zip |
Merge pull request #5753 from ethereum/docs-split-interfaces
[DOCS] Split interfaces into new file
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 38 | ||||
-rw-r--r-- | docs/contracts/interfaces.rst | 36 |
2 files changed, 37 insertions, 37 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index f72707cb..8d6e2fe4 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -534,43 +534,7 @@ converted to ``uint8``. .. include:: contracts/inheritance.rst .. include:: contracts/abstract-contracts.rst - -.. index:: ! contract;interface, ! interface contract - -.. _interfaces: - -********** -Interfaces -********** - -Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions: - -- They cannot inherit other contracts or interfaces. -- All declared functions must be external. -- They cannot declare a constructor. -- They cannot declare state variables. - -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: - -:: - - pragma solidity ^0.5.0; - - interface Token { - enum TokenType { Fungible, NonFungible } - struct Coin { string obverse; string reverse; } - function transfer(address recipient, uint amount) external; - } - -Contracts can inherit interfaces as they would inherit other contracts. - -Types defined inside interfaces and other contract-like structures -can be accessed from other contracts: ``Token.TokenType`` or ``Token.Coin``. +.. include:: contracts/interfaces.rst .. index:: ! library, callcode, delegatecall diff --git a/docs/contracts/interfaces.rst b/docs/contracts/interfaces.rst new file mode 100644 index 00000000..b551b518 --- /dev/null +++ b/docs/contracts/interfaces.rst @@ -0,0 +1,36 @@ +.. index:: ! contract;interface, ! interface contract + +.. _interfaces: + +********** +Interfaces +********** + +Interfaces are similar to abstract contracts, but they cannot have any functions implemented. There are further restrictions: + +- They cannot inherit other contracts or interfaces. +- All declared functions must be external. +- They cannot declare a constructor. +- They cannot declare state variables. + +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: + +:: + + pragma solidity ^0.5.0; + + interface Token { + enum TokenType { Fungible, NonFungible } + struct Coin { string obverse; string reverse; } + function transfer(address recipient, uint amount) external; + } + +Contracts can inherit interfaces as they would inherit other contracts. + +Types defined inside interfaces and other contract-like structures +can be accessed from other contracts: ``Token.TokenType`` or ``Token.Coin``. |