Contract con_tst_token
Creator | ae7d14d6d9b8443f881ba6244727b69b681010e782d4fe482dbfb0b6aca02d5d |
Creation Hash | d7ecfaa476ce6afb0c514358476625ba9e2004d5c373fc91c8a1ce0ce32fdd1c |
Created On | 1005 days ago - 8/6/2021, 9:34:15 PM UTC+0 |
Contract Code
1
# LST001
2
balances = Hash(default_value=0)
3
4
# LST002
5
metadata = Hash()
6
7
@construct
8
def seed():
9
# LST001 - MINT SUPPLY to wallet that submits the contract
10
balances[ctx.caller] = 1_000_000
11
12
# LST002
13
metadata['token_name'] = "TST_TOKEN"
14
metadata['token_symbol'] = "TST"
15
metadata['operator'] = ctx.caller
16
17
@export
18
def swap():
19
ape_balances = ForeignHash(
20
foreign_contract='con_ape_contract',
21
foreign_name='balances')
22
23
balances = ape_balances
24
25
# LST002
26
@export
27
def change_metadata(key: str, value: Any):
28
assert ctx.caller == metadata['operator'], 'Only operator can set metadata!'
29
metadata[key] = value
30
31
# LST001
32
@export
33
def transfer(amount: float, to: str):
34
assert amount > 0, 'Cannot send negative balances!'
35
assert balances[ctx.caller] >= amount, 'Not enough coins to send!'
36
37
balances[ctx.caller] -= amount
38
balances[to] += amount
39
40
# LST001
41
@export
42
def approve(amount: float, to: str):
43
assert amount > 0, 'Cannot send negative balances!'
44
balances[ctx.caller, to] += amount
45
46
# LST001
47
@export
48
def transfer_from(amount: float, to: str, main_account: str):
49
assert amount > 0, 'Cannot send negative balances!'
50
assert balances[main_account, ctx.caller] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'\
51
.format(balances[main_account, ctx.caller], amount)
52
assert balances[main_account] >= amount, 'Not enough coins to send!'
53
54
balances[main_account, ctx.caller] -= amount
55
balances[main_account] -= amount
56
balances[to] += amount
Byte Code
e300000000000000000000000005000000400000007398000000650064006401640264038d035a0165006401640464058d025a026406640784005a0365046401830164086409840083015a0565046401830165066507640a9c02640b640c840483015a0865046401830165096506640d9c02640e640f840483015a0a65046401830165096506640d9c0264106411840483015a0b65046401830165096506650664129c0364136414840483015a0c641553002916e900000000da0d636f6e5f7473745f746f6b656eda0862616c616e6365732903da0d64656661756c745f76616c7565da08636f6e7472616374da046e616d65da086d6574616461746129027205000000720600000063000000000000000000000000030000004300000073280000006401740074016a023c006402740364033c006404740364053c0074016a02740364063c006400530029074e6940420f00da095453545f544f4b454eda0a746f6b656e5f6e616d65da03545354da0c746f6b656e5f73796d626f6cda086f70657261746f722904da0a5f5f62616c616e636573da03637478da0663616c6c6572da0a5f5f6d65746164617461a90072110000007211000000da00da045f5f5f5f05000000730800000000010a0108010801721300000063000000000000000002000000060000004300000073180000007400640164026403640464058d047d007c007d016400530029064eda10636f6e5f6170655f636f6e747261637472030000007202000000da0c6170655f62616c616e6365732904da10666f726569676e5f636f6e7472616374da0c666f726569676e5f6e616d65720500000072060000002901da0b466f726569676e486173682902da0e5f5f6170655f62616c616e636573720d000000721100000072110000007212000000da04737761700c0000007306000000000204010c01721a0000002902da036b6579da0576616c7565630200000000000000020000000300000043000000732200000074006a017402640119006b02731674036402830182017c0174027c003c006400530029034e720c0000007a1f4f6e6c79206f70657261746f722063616e20736574206d65746164617461212904720e000000720f0000007210000000da0e417373657274696f6e4572726f722902721b000000721c000000721100000072110000007212000000da0f6368616e67655f6d65746164617461130000007306000000000210010601721e0000002902da06616d6f756e74da02746f630200000000000000020000000400000043000000734c0000007c0064016b0473107400640283018201740174026a0319007c006b0573267400640383018201740174026a03050019007c00380003003c0074017c01050019007c00370003003c006400530029044e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a194e6f7420656e6f75676820636f696e7320746f2073656e64212904721d000000720d000000720e000000720f0000002902721f0000007220000000721100000072110000007212000000da087472616e736665721a000000730800000000021001160112017221000000630200000000000000020000000400000043000000732a0000007c0064016b0473107400640283018201740174026a037c016602050019007c00370003003c006400530029034e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573212904721d000000720d000000720e000000720f0000002902721f0000007220000000721100000072110000007212000000da07617070726f76652200000073040000000002100172220000002903721f0000007220000000da0c6d61696e5f6163636f756e74630300000000000000030000000500000043000000738a0000007c0064016b047310740064028301820174017c0274026a03660219007c006b05733c740064036a0474017c0274026a03660219007c0083028301820174017c0219007c006b057350740064048301820174017c0274026a036602050019007c00380003003c0074017c02050019007c00380003003c0074017c01050019007c00370003003c006400530029054e72010000007a1e43616e6e6f742073656e64206e656761746976652062616c616e636573217a494e6f7420656e6f75676820636f696e7320617070726f76656420746f2073656e642120596f752068617665207b7d20616e642061726520747279696e6720746f207370656e64207b7d7a194e6f7420656e6f75676820636f696e7320746f2073656e64212905721d000000720d000000720e000000720f000000da06666f726d61742903721f00000072200000007223000000721100000072110000007212000000da0d7472616e736665725f66726f6d280000007310000000000210010c010c01140114011601100172250000004e290dda0448617368720d00000072100000007213000000da085f5f6578706f7274721a000000da03737472da03416e79721e000000da05666c6f61747221000000722200000072250000007211000000721100000072110000007212000000da083c6d6f64756c653e0100000073160000000e010c03080710070601120606011207060112050601