Contract con_uw_nft_energy


Contract Code

1 S = Hash(default_value='')
2 metadata = Hash(default_value=0)
3
4 @construct
5 def seed():
6 metadata['operator'] = ctx.caller
7 metadata['master_contract'] = 'con_uw_masters1'
8
9 @export
10 def change_metadata(key: str, value: Any):
11 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
12 metadata[key] = value
13
14
15 @export
16 def add_thing(thing_string: str, name: str, meta: dict, creator: str):
17 assert ctx.caller == metadata['master_contract'], 'Only operator can set metadata!'
18 uid = hashlib.sha256(thing_string)
19 assert not S[uid], thing_string + ' already exists'
20
21 S[uid] = ['thing', 'type', 'name', 'owner', 'creator', 'price:amount', 'meta_items']
22 S[uid, 'thing'] = thing_string
23 S[uid, 'type'] = 'text/plain'
24 S[uid, 'name'] = name
25 S[uid, 'owner'] = creator
26 S[uid, 'creator'] = creator
27 S[uid, 'price', 'amount'] = 0
28 S[uid, 'meta_items'] = ['drink']
29
30 S[uid, 'meta', 'drink'] = meta['drink']
31
32 return uid
33
34
35 @export
36 def thing_exists(thing_string: str):
37 uid = hashlib.sha256(thing_string)
38 return S[uid]
39
40
41
42
43 @export
44 def change_auction(uid: str, auction: bool):
45 assert ctx.caller == metadata['master_contract'], 'Only operator can set metadata!'
46 S[uid, 'auction'] = auction
47 return S[uid]
48 @export
49
50 def add_meta(uid: str, meta: str, value: Any):
51 assert ctx.caller == metadata['master_contract'], 'Only operator can set metadata!'
52 S[uid, 'meta', meta] = value
53 return S[uid]
54
55
56 @export
57 def get_owner(uid: str):
58 return S[uid, 'owner']
59
60 @export
61 def get_creator(uid: str):
62 return S[uid, 'creator']
63
64 @export
65 def set_price(uid: str, amount: float):
66 assert ctx.caller == metadata['master_contract'], 'Only operator can set metadata!'
67 assert amount >= 0, 'Cannot set a negative price'
68 S[uid, 'price', 'amount'] = amount
69
70 @export
71 def get_price_amount(uid: str):
72 return S[uid, 'price', 'amount']
73
74 @export
75 def get_auction(uid: str):
76 return S[uid, 'auction']
77
78
79 @export
80 def set_owner(uid: str, owner: str):
81 assert ctx.caller == metadata['master_contract'], 'Only operator can set metadata!'
82 S[uid, 'owner'] = owner

Byte Code

e30000000000000000000000000600000040000000732c010000650064006401640264038d035a01650064046401640564038d035a026406640784005a036504640183016505650664089c026409640a840483015a076504640183016505650565086505640b9c04640c640d840483015a096504640183016505640e9c01640f6410840483015a0a6504640183016505650b64119c0264126413840483015a0c65046401830165056505650664149c0364156416840483015a0d650464018301650564179c0164186419840483015a0e650464018301650564179c01641a641b840483015a0f65046401830165056510641c9c02641d641e840483015a11650464018301650564179c01641f6420840483015a12650464018301650564179c0164216422840483015a136504640183016505650564239c0264246425840483015a14642653002927da00da11636f6e5f75775f6e66745f656e65726779da01532903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65e900000000da086d65746164617461630000000000000000000000000300000043000000731600000074006a01740264013c006402740264033c006400530029044eda086f70657261746f72da13636f6e5f75775f6d61737465725f5f735f5f31da0f6d61737465725f636f6e74726163742903da03637478da0663616c6c6572da0a5f5f6d65746164617461a900720f000000720f0000007201000000da045f5f5f5f06000000730400000000010a0172100000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e72090000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904720c000000720d000000720e000000da0e417373657274696f6e4572726f72290272110000007212000000720f000000720f0000007201000000da0f6368616e67655f6d657461646174610b000000730600000000021001060172140000002904da0c7468696e675f737472696e677206000000da046d657461da0763726561746f7263040000000000000005000000070000004300000073ba00000074006a017402640119006b027316740364028301820174046a057c0083017d0474067c0419000c00733674037c006403170083018201640464056406640764086409640a670774067c043c007c0074067c04640466023c00640b74067c04640566023c007c0174067c04640666023c007c0374067c04640766023c007c0374067c04640866023c00640c74067c04640d640e66033c00640f670174067c04640a66023c007c02640f190074067c046410640f66033c007c04530029114e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461217a0f20616c726561647920657869737473da057468696e67da04747970657206000000da056f776e657272170000007a0c70726963653a616d6f756e74da0a6d6574615f6974656d737a0a746578742f706c61696e7207000000da057072696365da06616d6f756e74da056472696e6b72160000002907720c000000720d000000720e0000007213000000da07686173686c6962da06736861323536da035f5f5329057215000000720600000072160000007217000000da03756964720f000000720f0000007201000000da096164645f7468696e6712000000731e0000000002100106010a0116010c010a010c010c010c010c010c010e010e011201722300000029017215000000630100000000000000020000000200000043000000731200000074006a017c0083017d0174027c011900530029014e2903721f00000072200000007221000000290272150000007222000000720f000000720f0000007201000000da0c7468696e675f65786973747325000000730400000000020a01722400000029027222000000da0761756374696f6e630200000000000000020000000400000043000000732a00000074006a017402640119006b02731674036402830182017c0174047c00640366023c0074047c001900530029044e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612172250000002905720c000000720d000000720e00000072130000007221000000290272220000007225000000720f000000720f0000007201000000da0e6368616e67655f61756374696f6e2b00000073080000000002100106010c0172260000002903722200000072160000007212000000630300000000000000030000000500000043000000732c00000074006a017402640119006b02731674036402830182017c0274047c0064037c0166033c0074047c001900530029044e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612172160000002905720c000000720d000000720e000000721300000072210000002903722200000072160000007212000000720f000000720f0000007201000000da086164645f6d6574613300000073080000000002100106010e01722700000029017222000000630100000000000000010000000300000043000000730c00000074007c00640166021900530029024e721a0000002901722100000029017222000000720f000000720f0000007201000000da096765745f6f776e65723b000000730200000000027228000000630100000000000000010000000300000043000000730c00000074007c00640166021900530029024e72170000002901722100000029017222000000720f000000720f0000007201000000da0b6765745f63726561746f724000000073020000000002722900000029027222000000721d000000630200000000000000020000000500000043000000733800000074006a017402640119006b02731674036402830182017c0164036b05732674036404830182017c0174047c006405640666033c006400530029074e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d657461646174612172070000007a1b43616e6e6f74207365742061206e65676174697665207072696365721c000000721d0000002905720c000000720d000000720e0000007213000000722100000029027222000000721d000000720f000000720f0000007201000000da097365745f70726963654500000073080000000002100106011001722a000000630100000000000000010000000400000043000000730e00000074007c006401640266031900530029034e721c000000721d0000002901722100000029017222000000720f000000720f0000007201000000da106765745f70726963655f616d6f756e744d00000073020000000002722b000000630100000000000000010000000300000043000000730c00000074007c00640166021900530029024e72250000002901722100000029017222000000720f000000720f0000007201000000da0b6765745f61756374696f6e5200000073020000000002722c00000029027222000000721a000000630200000000000000020000000400000043000000732600000074006a017402640119006b02731674036402830182017c0174047c00640366023c006400530029044e720b0000007a1f4f6e6c79206f70657261746f722063616e20736574206d6574616461746121721a0000002905720c000000720d000000720e0000007213000000722100000029027222000000721a000000720f000000720f0000007201000000da097365745f6f776e6572570000007306000000000210010601722d0000004e2915da04486173687221000000720e0000007210000000da085f5f6578706f7274da03737472da03416e797214000000da046469637472230000007224000000da04626f6f6c7226000000722700000072280000007229000000da05666c6f6174722a000000722b000000722c000000722d000000720f000000720f000000720f0000007201000000da083c6d6f64756c653e0100000073320000000e01060108030805060112060601161206011005060112070601140706011004060110040601120706011004060110040601