-
Notifications
You must be signed in to change notification settings - Fork 2
/
chirp.clvm
55 lines (49 loc) · 1.58 KB
/
chirp.clvm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
(mod (STATE method args)
(include "condition_codes.clib")
(include "curry_and_treehash.clib")
(include "coinman.clvm")
(defun get-state-props ()
; state properties
(list "pk" "to")
)
(defun get-methods ()
; methods
(list
(list "send_message" "msg")
(list "get_messages" "start" "end")
)
)
(defun get-hints (STATE)
(if (get STATE "to")
(list (sha256 (point_add (get STATE "pk") (get STATE "to")))) ; direct message channel
(list (sha256 "catchall channel")) ; catchall channel
)
)
(def-contract STATE
(if (= method "send_message")
(list
(list AGG_SIG_ME (get STATE "pk") (sha256 (f args)) )
(list RECREATE_COIN
() ; no state update
1
(get-hints STATE) ; hints
)
)
(if (= method "get_messages")
(list
(list QUERY_COINS
; query filters
(list
(list "hint" (get-hints STATE))
(list "spent" 1)
)
; block range interval (max 100 blocks)
(list (f args) (f (r args)))
)
)
; default should return meta information for the contract
(list (list CONTRACT_META (get-state-props) (get-methods) (get-hints STATE)))
)
)
)
)