diff --git a/README.md b/README.md index 6250bfe..bd133cb 100644 --- a/README.md +++ b/README.md @@ -654,6 +654,36 @@ Use cases of sealing include: +### Throttle + +An backend contract to limit access to a resource by time. + +The smart contract managing the resource calls ‘have(address)‘ on this +contract to check if it can be made use of at the current point in time. +This also implements [ACL](#acl). + +When the resource is made use of, it calls ‘poke(address)‘ method to +register when it has been made use of. + +#### ERC165 Interface identifier + +8f5bc7bf + +#### Solidity interface definition + + interface IThrottle { + // Returns true if the given address is authorized to make use of the resource at the current moment. + // Implements ACL + function have(address _address) external view returns(bool); + + // Must be called when the resource is being used. + function poke(address _address) external returns(bool); + } + +#### Reference implementation + + (PeriodSimple contract) + ### TokenLimit Define limits of value amounts of tokens that individual addresses can diff --git a/doc/texinfo/acl.sol.texi b/doc/texinfo/acl.sol.texi index 1811f3c..5f2426b 100644 --- a/doc/texinfo/acl.sol.texi +++ b/doc/texinfo/acl.sol.texi @@ -1,3 +1,4 @@ +@anchor{acl} @subsection ACL A simple Access Control List definition that returns true of false depending on whether an signatory (address) is allowed to operate in a given context. diff --git a/doc/texinfo/overview.texi b/doc/texinfo/overview.texi index 9f6b9c5..a03ad4b 100644 --- a/doc/texinfo/overview.texi +++ b/doc/texinfo/overview.texi @@ -76,6 +76,8 @@ The following well-known solidity interfaces are partially implemented in CIC na @include seal.sol.texi +@include throttle.sol.texi + @include tokenlimit.sol.texi @include tokenquote.sol.texi diff --git a/doc/texinfo/throttle.sol.texi b/doc/texinfo/throttle.sol.texi new file mode 100644 index 0000000..7eec319 --- /dev/null +++ b/doc/texinfo/throttle.sol.texi @@ -0,0 +1,20 @@ +@subsection Throttle + +An backend contract to limit access to a resource by time. + +The smart contract managing the resource calls `have(address)` on this contract to check if it can be made use of at the current point in time. This also implements @ref{acl, ACL}. + +When the resource is made use of, it calls `poke(address)` method to register when it has been made use of. + + +@subsubsection ERC165 Interface identifier + +@include ../../build/Throttle.interface + +@subsubsection Solidity interface definition + +@include ../../build/contract_Throttle.texi + +@subsubsection Reference implementation + +@uref{git://holbrook.no/eth-faucet.git,} (PeriodSimple contract) diff --git a/python/README.md b/python/README.md index 6250bfe..bd133cb 100644 --- a/python/README.md +++ b/python/README.md @@ -654,6 +654,36 @@ Use cases of sealing include: +### Throttle + +An backend contract to limit access to a resource by time. + +The smart contract managing the resource calls ‘have(address)‘ on this +contract to check if it can be made use of at the current point in time. +This also implements [ACL](#acl). + +When the resource is made use of, it calls ‘poke(address)‘ method to +register when it has been made use of. + +#### ERC165 Interface identifier + +8f5bc7bf + +#### Solidity interface definition + + interface IThrottle { + // Returns true if the given address is authorized to make use of the resource at the current moment. + // Implements ACL + function have(address _address) external view returns(bool); + + // Must be called when the resource is being used. + function poke(address _address) external returns(bool); + } + +#### Reference implementation + + (PeriodSimple contract) + ### TokenLimit Define limits of value amounts of tokens that individual addresses can diff --git a/solidity/Throttle.sol b/solidity/Throttle.sol new file mode 100644 index 0000000..5eebe36 --- /dev/null +++ b/solidity/Throttle.sol @@ -0,0 +1,14 @@ +pragma solidity >=0.6.12; + +// Author: Louis Holbrook 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 +// SPDX-License-Identifier: AGPL-3.0-or-later +// File-version: 1 + +interface IThrottle { + // Returns true if the given address is authorized to make use of the resource at the current moment. + // Implements ACL + function have(address _address) external view returns(bool); + + // Must be called when the resource is being used. + function poke(address _address) external returns(bool); +}