Transaction #1035673

Hash 71028973d492e4f9d68f4c444d10593ad0de1c8e47a43bdb8b296f98c62d1118
Status Success
Timestamp 632 days ago - 8/27/2022, 10:46:59 AM UTC+0
Block 987438
Stamps Used 274
Burned Fee 0.01621302 TAU
From ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89 
Contract Name submission
Function Name submit_contract

Additional Info
SubBlock Number 0
Nonce 1772
Processor 5b09493df6c18d17cc883ebce54fcb1f5afbd507533417fe32c006009a9c3c4a
Signature 00833732dcb6de95dd7ca3ba87f1c2573e2d414e5b123dd2eca4b47c28a48f72d4d7c4dc02a2547d15c15715c223dd927b06fdd8d781fd6f92a0030147900004
Stamps Supplied 845
Stamps per TAU 169

Kwargs

code balances = Hash(default_value=0) holders_forward_index = Hash(default_value=False) holders_reverse_index = Hash(default_value=False) holders_amount = Variable() metadata = Hash() @construct def seed(): balances[ctx.caller] = 100_000_000 holders_amount.set(1) holders_forward_index[1] = ctx.caller holders_reverse_index[ctx.caller] = 1 metadata['token_name'] = "Rebase Example" metadata['token_symbol'] = "REBE" metadata['operator'] = ctx.caller metadata['rebase_balance_limit'] = 0 def manage_holders_index(address: str): if(not address.startswith("con_")): if(balances[address] > metadata['rebase_balance_limit']): if(holders_reverse_index[address] == False): new_holder_amount = holders_amount.get() + 1 holders_amount.set(new_holder_amount) reverse_holders_index[address] = new_holder_amount forward_holders_index[new_holder_amount] = address else: if (reverse_holders_index[address] != False): reverse_holders_index[address] = False forward_holders_index[new_holder_amount] = False @export def rebase_everyone(rebase_type: str, amount: float, start: int=None, end: int=None): assert ctx.caller == metadata['operator'], 'Only operator can rebase!' #start end for batches if too many stamps if start == None: start = 1 if end == None: end = holders_amount.get() + 1 if(rebase_type == "multiply"): for holder_id in range(start, end): if (forward_holders_index[holder_id] != False): balances[forward_holders_index[holder_id]] *= amount else: for holder_id in range(start, end): if (forward_holders_index[holder_id] != False): balances[forward_holders_index[holder_id]] /= amount @export def change_metadata(key: str, value: Any): assert ctx.caller == metadata['operator'], 'Only operator can set metadata!' metadata[key] = value @export def transfer(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' assert balances[ctx.caller] >= amount, 'Not enough coins to send!' balances[ctx.caller] -= amount balances[to] += amount manage_holders_index(ctx.caller) manage_holders_index(to) @export def approve(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' balances[ctx.caller, to] += amount @export def transfer_from(amount: float, to: str, main_account: str): assert amount > 0, 'Cannot send negative balances!' assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\ .format(balances[main_account, ctx.caller], amount) assert balances[main_account] >= amount, 'Not enough coins to send!' balances[main_account, ctx.caller] -= amount balances[main_account] -= amount balances[to] += amount manage_holders_index(main_account) manage_holders_index(to)
name con_rebase_example

State Changes

Contract con_rebase_example
Variable balances
Key ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
New Value 100000000
 
Contract con_rebase_example
Variable holders_amount
New Value 1
 
Contract con_rebase_example
Variable holders_forward_index
Key 1
New Value ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
 
Contract con_rebase_example
Variable holders_reverse_index
Key ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
New Value 1
 
Contract con_rebase_example
Variable metadata
Key token_name
New Value Rebase Example
 
Contract con_rebase_example
Variable metadata
Key token_symbol
New Value REBE
 
Contract con_rebase_example
Variable metadata
Key operator
New Value ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
 
Contract con_rebase_example
Variable metadata
Key rebase_balance_limit
New Value 0
 
Contract con_rebase_example
Variable __code__
New Value __balances = Hash(default_value=0, contract='con_rebase_example', name= 'balances') __holders_forward_index = Hash(default_value=False, contract= 'con_rebase_example', name='holders_forward_index') __holders_reverse_index = Hash(default_value=False, contract= 'con_rebase_example', name='holders_reverse_index') __holders_amount = Variable(contract='con_rebase_example', name= 'holders_amount') __metadata = Hash(contract='con_rebase_example', name='metadata') def ____(): __balances[ctx.caller] = 100000000 __holders_amount.set(1) __holders_forward_index[1] = ctx.caller __holders_reverse_index[ctx.caller] = 1 __metadata['token_name'] = 'Rebase Example' __metadata['token_symbol'] = 'REBE' __metadata['operator'] = ctx.caller __metadata['rebase_balance_limit'] = 0 def __manage_holders_index(address: str): if not address.startswith('con_'): if __balances[address] > __metadata['rebase_balance_limit']: if __holders_reverse_index[address] == False: new_holder_amount = __holders_amount.get() + 1 __holders_amount.set(new_holder_amount) reverse_holders_index[address] = new_holder_amount forward_holders_index[new_holder_amount] = address elif reverse_holders_index[address] != False: reverse_holders_index[address] = False forward_holders_index[new_holder_amount] = False @__export('con_rebase_example') def rebase_everyone(rebase_type: str, amount: float, start: int=None, end: int=None): assert ctx.caller == __metadata['operator'], 'Only operator can rebase!' if start == None: start = 1 if end == None: end = __holders_amount.get() + 1 if rebase_type == 'multiply': for holder_id in range(start, end): if forward_holders_index[holder_id] != False: __balances[forward_holders_index[holder_id]] *= amount else: for holder_id in range(start, end): if forward_holders_index[holder_id] != False: __balances[forward_holders_index[holder_id]] /= amount @__export('con_rebase_example') def change_metadata(key: str, value: Any): assert ctx.caller == __metadata['operator' ], 'Only operator can set metadata!' __metadata[key] = value @__export('con_rebase_example') def transfer(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' assert __balances[ctx.caller] >= amount, 'Not enough coins to send!' __balances[ctx.caller] -= amount __balances[to] += amount __manage_holders_index(ctx.caller) __manage_holders_index(to) @__export('con_rebase_example') def approve(amount: float, to: str): assert amount > 0, 'Cannot send negative balances!' __balances[ctx.caller, to] += amount @__export('con_rebase_example') def transfer_from(amount: float, to: str, main_account: str): assert amount > 0, 'Cannot send negative balances!' assert __balances[main_account, ctx.caller ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format( __balances[main_account, ctx.caller], amount) assert __balances[main_account] >= amount, 'Not enough coins to send!' __balances[main_account, ctx.caller] -= amount __balances[main_account] -= amount __balances[to] += amount __manage_holders_index(main_account) __manage_holders_index(to)
 
Contract con_rebase_example
Variable __compiled__
New Value e3000000000000000000000000070000004000000073dc000000650064006401640264038d035a01650064046401640564038d035a02650064046401640664038d035a0365046401640764088d025a0565006401640964088d025a06640a640b84005a076508640c9c01640d640e84045a09650a64018301641e6508650b650c650c64109c0464116412840583015a0d650a640183016508650e64139c0264146415840483015a0f650a64018301650b650864169c0264176418840483015a10650a64018301650b650864169c026419641a840483015a11650a64018301650b65086508641b9c03641c641d840483015a12640f5300291fe900000000da12636f6e5f7265626173655f6578616d706c65da0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d6546da15686f6c646572735f666f72776172645f696e646578da15686f6c646572735f726576657273655f696e646578da0e686f6c646572735f616d6f756e74290272050000007206000000da086d65746164617461630000000000000000000000000300000043000000734e0000006401740074016a023c0074036a0464028301010074016a02740564023c006402740674016a023c006403740764043c006405740764063c0074016a02740764073c006408740764093c0064005300290a4e6900e1f505e9010000007a0e526562617365204578616d706c65da0a746f6b656e5f6e616d65da0452454245da0c746f6b656e5f73796d626f6cda086f70657261746f727201000000da147265626173655f62616c616e63655f6c696d69742908da0a5f5f62616c616e636573da03637478da0663616c6c6572da105f5f686f6c646572735f616d6f756e74da03736574da175f5f686f6c646572735f666f72776172645f696e646578da175f5f686f6c646572735f726576657273655f696e646578da0a5f5f6d65746164617461a90072190000007219000000da00da045f5f5f5f0c000000731000000000010a010a010a010a01080108010a01721b0000002901da0761646472657373630100000000000000020000000300000043000000736e0000007c006a0064018301736a74017c0019007402640219006b04724e74037c00190064036b02726a74046a058300640417007d0174046a067c01830101007c0174077c003c007c0074087c013c006e1c74077c00190064036b03726a640374077c003c00640374087c013c006400530029054eda04636f6e5f721000000046720b0000002909da0a737461727473776974687211000000721800000072170000007214000000da036765747215000000da15726576657273655f686f6c646572735f696e646578da15666f72776172645f686f6c646572735f696e6465782902721c000000da116e65775f686f6c6465725f616d6f756e7472190000007219000000721a000000da165f5f6d616e6167655f686f6c646572735f696e64657817000000731400000000010a0110010c010c010a0108010a010c01080172230000004e2904da0b7265626173655f74797065da06616d6f756e74da057374617274da03656e6463040000000000000005000000050000004300000073ac00000074006a017402640119006b02731674036402830182017c0264006b02722264037d027c0364006b02723674046a058300640317007d037c0064046b027274786874067c027c03830244005d247d0474077c04190064056b03724a740874077c041900050019007c01390003003c00714a57006e34783274067c027c03830244005d247d0474077c04190064056b037280740874077c041900050019007c011d0003003c00718057006400530029064e720f0000007a194f6e6c79206f70657261746f722063616e2072656261736521720b000000da086d756c7469706c79462909721200000072130000007218000000da0e417373657274696f6e4572726f727214000000721f000000da0572616e67657221000000721100000029057224000000722500000072260000007227000000da09686f6c6465725f696472190000007219000000721a000000da0f7265626173655f65766572796f6e65240000007318000000000316010801040108010c01080110010c011a0210010c01722c0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720f0000007a1f4f6e6c79206f70657261746f722063616e20736574206d6574616461746121290472120000007213000000721800000072290000002902722d000000722e00000072190000007219000000721a000000da0f6368616e67655f6d65746164617461360000007306000000000210010601722f00000029027225000000da02746f630200000000000000020000000400000043000000735e0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c00740474026a038301010074047c01830101006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e642129057229000000721100000072120000007213000000722300000029027225000000723000000072190000007219000000721a000000da087472616e736665723d000000730c000000000210011601120110010a017231000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904722900000072110000007212000000721300000029027225000000723000000072190000007219000000721a000000da07617070726f7665470000007304000000000210017232000000290372250000007230000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000739a0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c0074057c028301010074057c01830101006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e642129067229000000721100000072120000007213000000da06666f726d61747223000000290372250000007230000000723300000072190000007219000000721a000000da0d7472616e736665725f66726f6d4d0000007314000000000210010c010c01140114011601100110010801723500000029024e4e2913da0448617368721100000072160000007217000000da085661726961626c6572140000007218000000721b000000da037374727223000000da085f5f6578706f7274da05666c6f6174da03696e74722c000000da03416e79722f000000723100000072320000007235000000721900000072190000007219000000721a000000da083c6d6f64756c653e01000000732a0000000601080104010a0104010a01040108010c03080b0e0d0601000118100601120606011209060112050601
 
Contract con_rebase_example
Variable __owner__
New Value null
 
Contract con_rebase_example
Variable __submitted__
New Value 2022,8,27,10,47,1,0
 
Contract con_rebase_example
Variable __developer__
New Value ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
 
Contract currency
Variable balances
Key ff61544ea94eaaeb5df08ed863c4a938e9129aba6ceee5f31b6681bdede11b89
New Value 336.266664481017889605102501841707