-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeystore.se
58 lines (51 loc) · 1.29 KB
/
keystore.se
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
56
57
58
# Key-Value Store
#
# API
#
# SERPENT
#
# # Get a value
# call(STORE, [GET, key], 2)
#
# # Set a value
# call(STORE, [SET, key, value], 3)
#
# # Kill the store (creator only)
# call(STORE, [KILL])
#
# ALETH
#
# data: "get" <key> # Get a value
# data: "set" <key> <value> # Set a value
# data: "kill" # Kill store (creator only)
#
shared:
GET = "get" * 256^(32 - 3)
SET = "set" * 256^(32 - 3)
KILL = "kill" * 256^(32 - 4)
REGISTER = "register" * 256^(32 - 8)
UNREGISTER = "unregister" * 256^(32 - 10)
NAMEREG = 0x748be5e613eb857fa9d1f8a1e4e5198376ccd989
init:
CREATOR = msg.sender
contract.storage[0] = CREATOR
NAME = "KeyStore!!" * 256^(32 - 10)
call(NAMEREG, [REGISTER, NAME], 2)
code:
command = msg.data[0]
arg1 = msg.data[1]
arg2 = msg.data[2]
if command == GET:
key = arg1
value = contract.storage[key]
return(value)
if command == SET:
key = arg1
value = arg2
contract.storage[key] = value
if command == KILL:
caller = msg.sender
CREATOR = contract.storage[0]
if caller == CREATOR:
call(NAMEREG, UNREGISTER)
suicide(CREATOR)