With penalty
Escrow with penalty
The escrow archetype presented below defines an escrow process with a penalty for the seller if the transaction fails (for example if it does not happen before the deadline).
Factoring is enabled: the seller can sell the “invoice” to a creditor, and the buyer can sell the penalty to a debtor.
A state machine is used to follow the different stages of the escrow transaction.
escrow_penalty.arl
1
archetype escrow_penalty
2
3
variable buyer : role = @tz1Lc2qBKEWCBeDU8npG6zCeCqpmaegRi6Jg
4
5
variable debitor : role = buyer
6
7
variable seller : role = @tz1bfVgcJC4ukaQSHUe1EbrUd5SekXeP9CWk
8
9
variable creditor : role = seller
10
11
variable oracle : role = @tz1iawHeddgggn6P5r5jtq2wDRqcJVksGVSa
12
13
variable price : tez = 10tz
14
15
variable penalty : tez = 0.1 * price
16
17
variable deadline : date = 2020-06-28T00:00:00
18
19
(* state machine *)
20
states =
21
| Created initial
22
| Aborted
23
| Confirmed
24
| Canceled
25
| Transferred with { i1 : balance = 0tz; }
26
27
transition abort () {
28
called by buyer or seller
29
30
from Created
31
to Aborted
32
}
33
34
transition confirm () {
35
from Created
36
to Confirmed when { balance = price + penalty }
37
}
38
39
transition transfer_ () {
40
called by oracle
41
42
from Confirmed
43
to Transferred when { now < deadline }
44
with effect {
45
transfer price to creditor;
46
transfer penalty to seller
47
}
48
}
49
50
transition cancel () {
51
called by oracle
52
53
from Confirmed
54
to Canceled
55
with effect {
56
transfer penalty to debitor;
57
transfer price to buyer
58
}
59
}
60
Copied!
Last modified 1yr ago
Export as PDF
Copy link