Fizzy
Real life insurance contract
The fizzy contract was an insurance against flight delay issued in 2018 by the Axa insurance company :
Below is the direct transcription of the fizzy contract in archetype.
fizzy.arl
1
archetype fizzy
2
3
variable creator : role = @tz1Lc2qBKEWCBeDU8npG6zCeCqpmaegRi6Jg
4
5
enum status =
6
| Created
7
| Before (* flight landed before the limit *)
8
| After (* flight landed after the limit *)
9
| Cancelled (* cancelled by the user *)
10
| FlightCancelled (* flight cancelled by the air company *)
11
| Redirected (* flight redirected *)
12
| Diverted (* flight diverted *)
13
14
asset insurance {
15
productid : string;
16
limit : date;
17
premium : tez;
18
indemnity : tez;
19
product : string;
20
stat : status = Created;
21
}
22
23
asset flight identified by id {
24
id : string;
25
insurances : partition<insurance>;
26
}
27
28
entry addflightinsurance (fi : string, iproductid : string, ilimit : date, ipremium : tez, iindemnity : tez, iproduct : string, istat : status) {
29
called by creator
30
31
effect {
32
if (not flight.contains (fi)) then
33
flight.add({ id = fi; insurances = [] });
34
flight[fi].insurances.add({iproductid; ilimit; ipremium; iindemnity; iproduct; istat})
35
}
36
}
37
38
(* data should be signed by oracle ... *)
39
entry updatestatus (fi : string, arrival : date) {
40
41
called by creator
42
43
effect {
44
for i in flight[fi].insurances do
45
match insurance[i].stat with
46
| Created ->
47
if arrival > insurance[i].limit
48
then insurance[i].stat := After
49
| _ -> ()
50
end
51
done
52
}
53
}
54
55
entry manual (fi : string, pr : string, newst : status) {
56
57
called by creator
58
59
effect {
60
for i in flight[fi].insurances.select(product = pr) do
61
match insurance[i].stat with
62
| Created -> insurance[i].stat := newst
63
| _ -> ()
64
end
65
done
66
}
67
}
68
69
security {
70
(* any action on storage is performed only by the owner *)
71
s1 : only_by_role (anyentry, creator);
72
}
73
Copied!
Last modified 1yr ago
Export as PDF
Copy link