Contract con_healer_npc_v3


Contract Code


  
1 I = importlib
2
3 heal_requests = Variable()
4 currency_contract = Variable()
5 cost = Variable()
6 owner = Variable()
7 operator = Variable()
8
9 @construct
10 def seed():
11 currency_contract.set("con_trt")
12 owner.set(ctx.caller)
13 operator.set("5fe2a80a2d0d4d7a08603451c02ac1ef5b1d0c6b3db118933e349d90a52deb44")
14 cost.set(100)
15 heal_requests.set([])
16
17 @export
18 def set_currency_contract(contract: str):
19 assert ctx.caller == owner.get(), "Only the owner can set the currency contract"
20 currency_contract.set(contract)
21
22 @export
23 def set_operator(new_operator: str):
24 assert ctx.caller == owner.get(), "Only the owner can set the operator"
25 operator.set(new_operator)
26
27 @export
28 def set_cost(new_cost: float):
29 assert ctx.caller == owner.get(), "Only the owner can set the cost"
30 cost.set(new_cost)
31
32 @export
33 def request_heal():
34 I.import_module(currency_contract.get()).transfer_from(amount=cost.get(), to="Burned", main_account=ctx.caller)
35 # dont allow duplicate requests
36 assert ctx.caller not in heal_requests.get(), "Request already made"
37 heal_requests_list = heal_requests.get()
38 heal_requests_list.append(ctx.caller)
39 heal_requests.set(heal_requests_list)
40
41
42 @export
43 def heal(address: str):
44 assert address in heal_requests.get(), "No heal request for this address"
45 assert ctx.caller == operator.get(), "Only the operator can heal"
46 heal_requests_list = heal_requests.get()
47 heal_requests_list.remove(address)
48 heal_requests.set(heal_requests_list)
49

Byte Code

e3000000000000000000000000040000004000000073b400000065005a0165026400640164028d025a0365026400640364028d025a0465026400640464028d025a0565026400640564028d025a0665026400640664028d025a076407640884005a08650964008301650a64099c01640a640b840483015a0b650964008301650a640c9c01640d640e840483015a0c650964008301650d640f9c0164106411840483015a0e65096400830164126413840083015a0f650964008301650a64149c0164156416840483015a10641753002918da11636f6e5f6865616c65725f6e70635f7633da0d6865616c5f72657175657374732902da08636f6e7472616374da046e616d65da1163757272656e63795f636f6e7472616374da04636f7374da056f776e6572da086f70657261746f72630000000000000000000000000200000043000000733800000074006a0164018301010074026a0174036a048301010074056a0164028301010074066a0164038301010074076a016700830101006400530029044eda07636f6e5f747274da4035666532613830613264306434643761303836303334353163303261633165663562316430633662336462313138393333653334396439306135326465623434e9640000002908da135f5f63757272656e63795f636f6e7472616374da03736574da075f5f6f776e6572da03637478da0663616c6c6572da0a5f5f6f70657261746f72da065f5f636f7374da0f5f5f6865616c5f7265717565737473a90072140000007214000000da00da045f5f5f5f0a000000730c00000000010a010c01040106010a01721600000029017203000000630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a2c4f6e6c7920746865206f776e65722063616e20736574207468652063757272656e637920636f6e74726163742907720f0000007210000000720e000000da03676574da0e417373657274696f6e4572726f72720c000000720d00000029017203000000721400000072140000007215000000da157365745f63757272656e63795f636f6e747261637413000000730600000000021001060172190000002901da0c6e65775f6f70657261746f72630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a234f6e6c7920746865206f776e65722063616e2073657420746865206f70657261746f722907720f0000007210000000720e000000721700000072180000007211000000720d0000002901721a000000721400000072140000007215000000da0c7365745f6f70657261746f721a000000730400000000021601721b0000002901da086e65775f636f7374630100000000000000010000000200000043000000732400000074006a0174026a0383006b027316740464018301820174056a067c00830101006400530029024e7a1f4f6e6c7920746865206f776e65722063616e207365742074686520636f73742907720f0000007210000000720e000000721700000072180000007212000000720d0000002901721c000000721400000072140000007215000000da087365745f636f737420000000730400000000021601721d000000630000000000000000010000000500000043000000735800000074006a0174026a03830083016a0474056a038300640174066a0764028d03010074066a0774086a0383006b077336740964038301820174086a0383007d007c006a0a74066a078301010074086a0b7c00830101006400530029044eda064275726e65642903da06616d6f756e74da02746fda0c6d61696e5f6163636f756e747a145265717565737420616c7265616479206d616465290cda0149da0d696d706f72745f6d6f64756c65720c0000007217000000da0d7472616e736665725f66726f6d7212000000720f000000721000000072130000007218000000da06617070656e64720d0000002901da126865616c5f72657175657374735f6c697374721400000072140000007215000000da0c726571756573745f6865616c26000000730c000000000214010c01160108010c0172270000002901da0761646472657373630100000000000000020000000200000043000000734a0000007c0074006a0183006b067314740264018301820174036a0474056a0183006b02732a740264028301820174006a0183007d017c016a067c008301010074006a077c01830101006400530029034e7a204e6f206865616c207265717565737420666f72207468697320616464726573737a1a4f6e6c7920746865206f70657261746f722063616e206865616c2908721300000072170000007218000000720f00000072100000007211000000da0672656d6f7665720d000000290272280000007226000000721400000072140000007215000000da046865616c30000000730a00000000021401160108010a01722a0000004e2911da09696d706f72746c69627222000000da085661726961626c657213000000720c0000007212000000720e00000072110000007216000000da085f5f6578706f7274da037374727219000000721b000000da05666c6f6174721d0000007227000000722a0000007214000000721400000072140000007215000000da083c6d6f64756c653e01000000732000000004010c01040108010c010c010c030809060110060601100506011005100a0601