Interface
The smart contract is developed with the Archetype language.
Storage
Address of the contract owner only capable of collecting payments and setting parameters:
variable owner : address = @tz1h4CiqWxNe4UxSpkwXy617RM6DaK6NU76P
Start date of service:
variable dateofstop : date = now
End date of service (the service is off if in the past, on otherwize):
variable dateofstart : date = now
Number of minutes of service mimutes par XTZ sent:
variable rate : rational = 1.2 // in time_unit / tez_unit
Time unit:
variable time_unit : duration = 1m
Tez unit:
variable tez_unit : tez = 1tz
Last/current customer address:
variable user : option<address> = none
Duration between two state lookups by the connected object:
variable read_interval : duration = 5s
Entry points
start
entry start () {
require {
r1: now > dateofstop;
}
effect {
...
}
}
interrupt
It is possible to interrupt the service before its planned end of service date by calling this entry point. In that case, the smart contract pays the caller back in proportion of the service duration without any penalty.
entry interrupt () {
require {
r2: caller = opt_get(user) and now < dateofstop
}
effect {
...
}
}
collect
Called by owner
to collect service payments:
entry collect () {
called by owner
effect {
...
}
}
set unit
entry setunits (dunit : duration, tunit : tez) {
called by owner
effect {
...
}
}