-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeystore.lll
52 lines (50 loc) · 1.02 KB
/
keystore.lll
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
;; KeyStore
;;
;; A key-value store contract for Ethereum
;;
;; API
;;
;; LLL
;;
;; # Get a value
;; [0] "get"
;; [32] <key>
;; (msg (gas) KEYSTORE 0 0 64)
;;
;; # Set a value
;; [0] "set"
;; [32] <key>
;; [64] <value>
;; (msg (gas) KEYSTORE 0 0 96)
;;
;; # Kill the contract (creator only)
;; (msg KEYSTORE "kill")
;;
;; ALETH
;;
;; data: "get" <key> # Get value
;; data: "set" <key> <value> # Set value
;; data: "kill" # Kill contract
;;
{
;; Init
(def 'regname (name) {
[0] "register"
[32] name
(call (- (gas) 100) NAMEREG 0 0 64 0 0)
})
(def 'NAMEREG 0xf7cc345a7885a8fb54f16bcbd726e08a7c300bd4)
(def 'NAME 'KeyStore) (regname NAME)
(def 'CREATOR 69) [[ CREATOR ]] (caller)
;; Code
(returnlll {
(def 'command $0)
(def 'key $32)
(def 'value $64)
(when (= command 'get) (return @@key))
(when (= command 'set) [[ key ]] value )
(when (&& (= command 'kill)
(= (caller) @@CREATOR))
(suicide @@CREATOR))
})
}