Skip to main content

Interrupt

It is possible to interrupt the service by clicking the "Interrupt" button:

Docusaurus with Keytar

It generates the following transaction parameter:

[{    "kind":"transaction"    "to":"KT1CxHBiCSvmXn9kXCbhPfdGDAggGG9ktQEX"    "amount":0    "mutez":true    "parameter":{        "entrypoint":"interrupt"        "value":{            "prim":"Unit"        }    }}]

It is possible to check the corresponding transactions in the Better Call Dev indexer:

Docusaurus with Keytar

We note in the screenshot above that the smart contract pays back to the caller an amount in prorata of the session duration, as formulated in the smart contract interrupt entry point:

function get_return_tz () : tez {    var res : int = 1 / get_rate_in_s_by_utz() * (dateofstop - now);    return (res * 1utz)}
entry interrupt () {    require {        r2: caller = opt_get(user) and now < dateofstop    }    effect {        transfer (get_return_tz()) to caller;        dateofstop  := now - read_interval;        dateofstart := now - read_interval;    }}