Signed-off-by: lash <email@example.com>
A faucet implementation for ETH gas tokens, implementing the CIC Faucet interface.
Firstly, the faucet contract must be funded before use. It can be funded simply by sending gas tokens to it as a normal transaction.
Secondly, the amount of gas tokens to emit must be changed using the
setAmount() method. Only the contract "owner" or a "writer" (see below) may change the amount. The amount can be changed again at any time, until sealed.
To receive gas tokens from the faucet, the method
gimme() is used. The latter will send gas tokens to the address that signed the transaction.
Usage of the faucet may be restricted by which addresses can request gas tokens from it.
The list must be provided by a contract implementing the CIC ACL interface. The contract to use is defined using the
Restricting usage frequency
Usage of the faucet may also be restricted by time delay.
The usage control must be provided by a smart contract implementing the CIC Throttle interface. The contract to use is defined using the
Example usage frequency controller
PeriodSimple contract provided by this repository demonstrates an implementation of the usage frequency restriction.
Only a single address has access to call the
poke(address) method. This address is typically the contract providing the resource, and is defined by calling the
The number of seconds that must pass between each usage can be set using
setBalanceThreshold() a maximum balance can be defined, to disallow use for addresses holding higher balances. (Note that this does not provide any real protection against agents, for example non-custioal wallets, that can forward the gas tokens at will).
Sealing the contracts
The faucet contract implements the CIC Seal interface to enable sealing the parameters defining its behavior.
The parameters that can be sealed are:
- Registry, blocking the use of the
- Period checker, blocking the use of the
- Value, blocking the use of the
The PeriodSimple contract does not implement the seal, but may discard ownedship through the EIP173 interface, after which no parameters changing behavior can be modified.