Contract con_dope_as_fuck_bro


Contract Code


  
1 import currency as tau
2 I = importlib
3
4 random.seed()
5
6 balances = Hash(default_value=0)
7 metadata = Hash()
8
9 minted = Variable()
10 burned = Variable()
11
12 last_mint = Variable()
13
14 max_supply = 500_000
15 initial_mint = 1_000
16
17 @construct
18 def seed():
19 last_mint.set(now)
20 minted.set(initial_mint)
21 burned.set(0)
22
23 balances[ctx.caller] = initial_mint
24
25 metadata['token_name'] = "KING Token"
26 metadata['token_symbol'] = "KING"
27 metadata['operator'] = ctx.caller
28
29 @export
30 def change_metadata(key: str, value: Any):
31 assert ctx.caller == metadata['operator'], 'Not allowed'
32 metadata[key] = value
33
34 @export
35 def balance_of(address: str):
36 return balances[address]
37
38 @export
39 def transfer(amount: float, to: str):
40 assert amount > 0, 'Cannot send negative balances!'
41 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
42
43 balances[ctx.caller] -= amount
44 balances[to] += amount
45
46 @export
47 def approve(amount: float, to: str):
48 assert amount > 0, 'Cannot send negative balances!'
49 balances[ctx.caller, to] += amount
50
51 @export
52 def transfer_from(amount: float, to: str, main_account: str):
53 approved = balances[main_account, ctx.caller]
54
55 assert approved >= amount, f'You approved {approved} but need {amount}'
56 assert balances[main_account] >= amount, 'Not enough coins to send!'
57 assert amount > 0, 'Cannot send negative balances!'
58
59 balances[main_account, ctx.caller] -= amount
60 balances[main_account] -= amount
61 balances[to] += amount
62
63 def transfer_internal(amount: float, to: str, main_account: str):
64 assert balances[main_account] >= amount, 'Not enough coins to send!'
65 assert amount > 0, 'Cannot send negative balances!'
66
67 balances[main_account] -= amount
68 balances[to] += amount
69
70 @export
71 def mint():
72 tau.transfer_from(amount=10, to=ctx.this, main_account=ctx.caller)
73
74 if now < last_mint.get() + datetime.timedelta(seconds=random.randint(1, 6)): return
75 if ctx.caller.startswith('con_'): return
76 if minted.get() >= max_supply: return
77
78 tau.transfer(amount=9, to=ctx.caller)
79
80 counter = initial_mint
81 for x in range(counter, minted.get() + 1):
82 counter += 1
83
84 last_mint.set(now)
85 minted.set(counter)
86 balances[ctx.caller] += 1
87
88 return 'MINTED'
89
90 @export
91 def redeem(amount: float):
92 transfer_internal(amount=amount, to='BURN_ADDRESS', main_account=ctx.caller)
93 tau.transfer(amount=amount, to=ctx.caller)
94 burned.set(burned.get() + amount)
95
96 @export
97 def payout():
98 amount = tau.balance_of(ctx.this) - (minted.get() - burned.get() - initial_mint)
99 assert ctx.caller == metadata['operator'], 'Not allowed'
100 tau.transfer(amount=amount, to=metadata['operator'])
101

Byte Code

e300000000000000000000000005000000400000007326010000640064016c005a0165025a0365046a0583000100650664006402640364048d035a0765066402640564068d025a0865096402640764068d025a0a65096402640864068d025a0b65096402640964068d025a0c640a5a0d640b5a0e640c640d84005a0f65106402830165116512640e9c02640f6410840483015a13651064028301651164119c0164126413840483015a146510640283016515651164149c0264156416840483015a166510640283016515651164149c0264176418840483015a1765106402830165156511651164199c03641a641b840483015a1865156511651164199c03641c641d84045a19651064028301641e641f840083015a1a651064028301651564209c0164216422840483015a1b65106402830164236424840083015a1c640153002925e9000000004eda14636f6e5f646f70655f61735f6675636b5f62726fda0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da066d696e746564da066275726e6564da096c6173745f6d696e746920a1070069e8030000630000000000000000000000000300000043000000734600000074006a0174028301010074036a0174048301010074056a016401830101007404740674076a083c006402740964033c006404740964053c0074076a08740964063c006400530029074e72010000007a0a4b494e4720546f6b656eda0a746f6b656e5f6e616d65da044b494e47da0c746f6b656e5f73796d626f6cda086f70657261746f72290ada0b5f5f6c6173745f6d696e74da03736574da036e6f77da085f5f6d696e746564da0c696e697469616c5f6d696e74da085f5f6275726e6564da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072190000007219000000da00da045f5f5f5f0e000000730e00000000010a010a010a010a0108010801721b0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720e0000007a0b4e6f7420616c6c6f7765642904721600000072170000007218000000da0e417373657274696f6e4572726f722902721c000000721d00000072190000007219000000721a000000da0f6368616e67655f6d6574616461746118000000730400000000021601721f0000002901da0761646472657373630100000000000000010000000200000043000000730800000074007c001900530029014e290172150000002901722000000072190000007219000000721a000000da0a62616c616e63655f6f661e0000007302000000000272210000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904721e00000072150000007216000000721700000029027222000000722300000072190000007219000000721a000000da087472616e7366657223000000730800000000021001160112017224000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721e00000072150000007216000000721700000029027222000000722300000072190000007219000000721a000000da07617070726f76652b0000007304000000000210017225000000290372220000007223000000da0c6d61696e5f6163636f756e74630300000000000000040000000500000043000000738800000074007c0274016a02660219007d037c037c006b05732a740364017c039b0064027c009b009d048301820174007c0219007c006b05733e74036403830182017c0064046b04734e740364058301820174007c0274016a026602050019007c00380003003c0074007c02050019007c00380003003c0074007c01050019007c00370003003c006400530029064e7a0d596f7520617070726f766564207a0a20627574206e656564207a194e6f7420656e6f75676820636f696e7320746f2073656e642172010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721500000072160000007217000000721e0000002904722200000072230000007226000000da08617070726f76656472190000007219000000721a000000da0d7472616e736665725f66726f6d31000000730e00000000020e011c0114011001160110017228000000630300000000000000030000000400000043000000734800000074007c0219007c006b05731474016401830182017c0064026b047324740164038301820174007c02050019007c00380003003c0074007c01050019007c00370003003c006400530029044e7a194e6f7420656e6f75676820636f696e7320746f2073656e642172010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e6365732129027215000000721e000000290372220000007223000000722600000072190000007219000000721a000000da135f5f7472616e736665725f696e7465726e616c3c00000073080000000001140110011001722900000063000000000000000002000000060000004300000073ba00000074006a01640174026a0374026a0464028d030100740574066a07830074086a09740a6a0b64036404830264058d0117006b0072386400530074026a046a0c64068301724864005300740d6a078300740e6b0572586400530074006a0f640774026a0464088d02010074107d00782274117c00740d6a07830064031700830244005d0c7d017c00640337007d007180570074066a12740583010100740d6a127c0083010100741374026a04050019006403370003003c0064095300290a4ee90a0000002903722200000072230000007226000000e901000000e9060000002901da077365636f6e6473da04636f6e5fe909000000290272220000007223000000da064d494e5445442914da0374617572280000007216000000da047468697372170000007211000000720f000000da03676574da086461746574696d65da0974696d6564656c7461da0672616e646f6dda0772616e64696e74da0a737461727473776974687212000000da0a6d61785f737570706c7972240000007213000000da0572616e6765721000000072150000002902da07636f756e746572da017872190000007219000000721a000000da046d696e74430000007320000000000214011001100104010c0104010c0104011001040118010c010a010a011201723d00000029017222000000630100000000000000010000000500000043000000733600000074007c00640174016a0264028d03010074036a047c0074016a0264038d02010074056a0674056a0783007c001700830101006400530029044eda0c4255524e5f4144445245535329037222000000722300000072260000002902722200000072230000002908722900000072160000007217000000723100000072240000007214000000721000000072330000002901722200000072190000007219000000721a000000da0672656465656d570000007306000000000210021001723f000000630000000000000000010000000400000043000000734c00000074006a0174026a03830174046a05830074066a05830018007407180018007d0074026a087409640119006b027336740a64028301820174006a0b7c0074096401190064038d0201006400530029044e720e0000007a0b4e6f7420616c6c6f776564290272220000007223000000290c7231000000722100000072160000007232000000721200000072330000007214000000721300000072170000007218000000721e00000072240000002901722200000072190000007219000000721a000000da067061796f75745f000000730800000000021801080116017240000000291dda0863757272656e63797231000000da09696d706f72746c6962da01497236000000da0473656564da044861736872150000007218000000da085661726961626c6572120000007214000000720f00000072390000007213000000721b000000da085f5f6578706f7274da03737472da03416e79721f0000007221000000da05666c6f61747224000000722500000072280000007229000000723d000000723f0000007240000000721900000072190000007219000000721a000000da083c6d6f64756c653e010000007334000000080104010801060108010c010c010c010c0104010403080a060112050601100406011207060112050601140a1207101406011007