Contract con_takkashi


Contract Code


  
1 balances = Hash(default_value=0)
2 metadata = Hash()
3
4
5 # We will burn a certain amount of each tx until the total supply is at 1.333.777
6 # A max of 10 TAK is burned at once per tx though.
7 BurnRate = Variable()
8 MinSupply = Variable()
9 MaxSupply = Variable()
10 MaxBurn = Variable()
11 BurnAddress = Variable()
12
13
14 @construct
15 def seed(supply=61616161):
16 # Mint supply
17 balances['d1a8a1427a76bbd6f6132be15a69ea9bdde67af0cca0e429f41e4d85516c529d'] = supply
18
19 # define metadata
20 metadata['token_name'] = "Takkashi"
21 metadata['token_symbol'] = "TAK"
22 metadata['operator'] = 'd1a8a1427a76bbd6f6132be15a69ea9bdde67af0cca0e429f41e4d85516c529d'
23
24 MaxSupply.set(supply)
25 MinSupply.set(1333777.00000)
26 MaxBurn.set(10.00000)
27 BurnRate.set(0.01)
28 BurnAddress.set(
29 "0000000000000000000000000000000000000000000000000000000000000001")
30
31 # Burn the correct amount
32 def burn(amount: float):
33 difference = MaxSupply.get() - MinSupply.get()
34
35 if balances[BurnAddress.get()] < difference:
36 amountToBurn = amount * BurnRate.get()
37 if amountToBurn <= MaxBurn.get():
38 return amount * BurnRate.get()
39 else:
40 return MaxBurn.get()
41 else:
42 return 0
43
44 @export
45 def change_metadata(key: str, value: Any):
46 assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
47 metadata[key] = value
48
49 # LST001
50 @export
51 def transfer(amount: float, to: str):
52 assert amount > 0, 'Cannot send negative balances!'
53 assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
54
55 burned_tokens = burn(amount)
56 assert burned_tokens <= MaxBurn.get(
57 ), 'You are trying to burn more tokens than you should!'
58
59 balances[ctx.caller] -= amount
60 balances[to] += (amount - burned_tokens)
61 balances[BurnAddress.get()] += burned_tokens
62
63 # LST001
64 @export
65 def approve(amount: float, to: str):
66 assert amount > 0, 'Cannot send negative balances!'
67 balances[ctx.caller, to] += amount
68
69 # LST001
70 @export
71 def transfer_from(amount: float, to: str, main_account: str):
72 assert amount > 0, 'Cannot send negative balances!'
73 assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}' \
74 .format(balances[main_account, ctx.caller], amount)
75 assert balances[main_account] >= amount, 'Not enough coins to send!'
76
77 burned_tokens = burn(amount)
78 assert burned_tokens <= MaxBurn.get(
79 ), 'You are trying to burn more tokens than you should!'
80
81 balances[main_account, ctx.caller] -= amount
82 balances[main_account] -= amount
83 balances[to] += (amount - burned_tokens)
84 balances[BurnAddress.get()] += burned_tokens
85

Byte Code

e3000000000000000000000000050000004000000073d4000000650064006401640264038d035a0165006401640464058d025a0265036401640664058d025a0465036401640764058d025a0565036401640864058d025a0665036401640964058d025a0765036401640a64058d025a08641d640c640d84015a09650a640e9c01640f641084045a0b650c64018301650d650e64119c0264126413840483015a0f650c64018301650a650d64149c0264156416840483015a10650c64018301650a650d64149c0264176418840483015a11650c64018301650a650d650d64199c03641a641b840483015a12641c5300291ee900000000da0c636f6e5f74616b6b61736869da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d65746164617461290272050000007206000000da084275726e52617465da094d696e537570706c79da094d6178537570706c79da074d61784275726eda0b4275726e41646472657373e92130ac0363010000000000000001000000030000004300000073620000007c00740064013c006402740164033c006404740164053c006401740164063c0074026a037c008301010074046a037405640783018301010074066a037405640883018301010074076a037405640983018301010074086a03640a8301010064005300290b4eda4064316138613134323761373662626436663631333262653135613639656139626464653637616630636361306534323966343165346438353531366335323964da0854616b6b61736869da0a746f6b656e5f6e616d65da0354414bda0c746f6b656e5f73796d626f6cda086f70657261746f727a09313333333737372e307a0431302e307a04302e3031da40303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030312909da0a5f5f62616c616e636573da0a5f5f6d65746164617461da0b5f5f4d6178537570706c79da03736574da0b5f5f4d696e537570706c79da07646563696d616cda095f5f4d61784275726eda0a5f5f4275726e52617465da0d5f5f4275726e416464726573732901da06737570706c79a900721f000000da00da045f5f5f5f0a0000007314000000000308010801080208010a010e010e010e01040172210000002901da06616d6f756e74630100000000000000030000000200000043000000735600000074006a01830074026a01830018007d01740374046a01830019007c016b00724e7c0074056a01830014007d027c0274066a0183006b0172447c0074056a0183001400530074066a01830053006e04640153006400530029024e720100000029077217000000da0367657472190000007215000000721d000000721c000000721b00000029037222000000da0a646966666572656e6365da0c616d6f756e74546f4275726e721f000000721f0000007220000000da065f5f6275726e1a000000730e0000000001100110010c010c010c020a0272260000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e72130000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904da03637478da0663616c6c65727216000000da0e417373657274696f6e4572726f72290272270000007228000000721f000000721f0000007220000000da0f6368616e67655f6d65746164617461260000007306000000000210010601722c00000029027222000000da02746f63020000000000000003000000050000004300000073800000007c0064016b0473107400640283018201740174026a0319007c006b057326740064038301820174047c0083017d027c0274056a0683006b0173427400640483018201740174026a03050019007c00380003003c0074017c01050019007c007c021800370003003c00740174076a068300050019007c02370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64217a33596f752061726520747279696e6720746f206275726e206d6f726520746f6b656e73207468616e20796f752073686f756c64212908722b00000072150000007229000000722a0000007226000000721b0000007223000000721d00000029037222000000722d000000da0d6275726e65645f746f6b656e73721f000000721f0000007220000000da087472616e736665722d000000731000000000021001160108010e01060112011401722f000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904722b00000072150000007229000000722a00000029027222000000722d000000721f000000721f0000007220000000da07617070726f766539000000730400000000021001723000000029037222000000722d000000da0c6d61696e5f6163636f756e7463030000000000000004000000050000004300000073be0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174057c0083017d037c0374066a0783006b01736c740064058301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c007c031800370003003c00740174086a078300050019007c03370003003c006400530029064e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64217a33596f752061726520747279696e6720746f206275726e206d6f726520746f6b656e73207468616e20796f752073686f756c64212909722b00000072150000007229000000722a000000da06666f726d61747226000000721b0000007223000000721d00000029047222000000722d0000007231000000722e000000721f000000721f0000007220000000da0d7472616e736665725f66726f6d3f0000007318000000000210010c010c011401140108010e01060116011001140172330000004e2901720d0000002913da044861736872150000007216000000da085661726961626c65721c00000072190000007217000000721b000000721d0000007221000000da05666c6f61747226000000da085f5f6578706f7274da03737472da03416e79722c000000722f00000072300000007233000000721f000000721f000000721f0000007220000000da083c6d6f64756c653e0100000073200000000e010c010c010c010c010c010c030a100e0c060112060601120b060112050601