tx · E86wfZdkYvG9E1CkZMygdRWetv9QA4EGakWJ8DNapD6j 3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8: -0.01000000 Waves 2022.02.21 12:16 [1933223] smart account 3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8 > SELF 0.00000000 Waves
{ "type": 13, "id": "E86wfZdkYvG9E1CkZMygdRWetv9QA4EGakWJ8DNapD6j", "fee": 1000000, "feeAssetId": null, "timestamp": 1645434956782, "version": 2, "chainId": 84, "sender": "3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8", "senderPublicKey": "6so6qVTu5xitJ3xkhqQ3AiC1noyJFbQF84JTjfW1uZTr", "proofs": [ "2K25GFx1XerhksHGq16keDiPiit7Ubwykmftx5cS1hXJnjZYfb2dCFb5BpyzNiW4cW4hjWivF4bZgEmScjtQq1y1" ], "script": "base64:AAIFAAAAAAAAAB4IAhIHCgUICAgEARIDCgEIEgUKAwgEARIFCgMIBAEAAAAJAAAAAAdmb3VuZGVyCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFUPGJVmVN3MQyGoyZcUpjWWXz98qyJHue+AAAAABFDb21taXNzaW9uUGVyY2VudAAAAAAAAAAABQAAAAAIU3RhdHVzTmECAAAADU5PVF9BVkFJTEFCTEUAAAAADlN0YXR1c1RyYWRhYmxlAgAAAAhUUkFEQUJMRQAAAAARU3RhdHVzTm90VHJhZGFibGUCAAAADE5PVF9UUkFEQUJMRQEAAAAQZ2V0VG9rZW5Pd25lcktleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAAMdG9rZW5fb3duZXJfCQACWAAAAAEFAAAABXRva2VuAQAAABFnZXRUb2tlblN0YXR1c0tleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAANdG9rZW5fc3RhdHVzXwkAAlgAAAABBQAAAAV0b2tlbgEAAAAQZ2V0VG9rZW5QcmljZUtleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAAMdG9rZW5fcHJpY2VfCQ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d25lcgUAAAAMY3VycmVudFByaWNlBQAAAAR1bml0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAB2ZvdW5kZXIFAAAADnJlYWxDb21taXNzaW9uBQAAAAR1bml0CQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAABBnZXRUb2tlbk93bmVyS2V5AAAAAQUAAAAHYXNzZXRJZAUAAAATY2FsbGVyQWRkcmVzc1N0cmluZwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAARZ2V0VG9rZW5TdGF0dXNLZXkAAAABBQAAAAdhc3NldElkCQEAAAAMYm9vbFRvU3RhdHVzAAAAAQUAAAAKaXNUcmFkYWJsZQkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEGdldFRva2VuUHJpY2VLZXkAAAABBQAAAAdhc3NldElkBQAAAAhuZXdQcmljZQUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkIYXOt", "height": 1933223, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 79UmBhn3LHMrm3EUnCAnG4GHVN674EEKeNDvx7R56wAZ Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let founder = Address(base58'3MuRN7peEs8ezRsgKGN7PmWzChkEkEp19ru') | |
5 | + | ||
6 | + | let CommissionPercent = 5 | |
7 | + | ||
8 | + | let StatusNa = "NOT_AVAILABLE" | |
9 | + | ||
10 | + | let StatusTradable = "TRADABLE" | |
11 | + | ||
12 | + | let StatusNotTradable = "NOT_TRADABLE" | |
13 | + | ||
14 | + | func getTokenOwnerKey (token) = ("token_owner_" + toBase58String(token)) | |
15 | + | ||
16 | + | ||
17 | + | func getTokenStatusKey (token) = ("token_status_" + toBase58String(token)) | |
18 | + | ||
19 | + | ||
20 | + | func getTokenPriceKey (token) = ("token_price_" + toBase58String(token)) | |
21 | + | ||
22 | + | ||
23 | + | func boolToStatus (value) = if ((value == true)) | |
24 | + | then StatusTradable | |
25 | + | else StatusNotTradable | |
26 | + | ||
27 | + | ||
28 | + | @Callable(i) | |
29 | + | func mint (ownerAddress,name,description,isTradable,price) = if ((founder != i.caller)) | |
30 | + | then throw("Method only for founder") | |
31 | + | else { | |
32 | + | let asset = Issue(name, description, 1, 0, false) | |
33 | + | let assetId = calculateAssetId(asset) | |
34 | + | [ScriptTransfer(i.caller, 1, assetId), StringEntry(getTokenOwnerKey(assetId), ownerAddress), StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), price)] | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | @Callable(i) | |
40 | + | func pickUp (assetIdString) = { | |
41 | + | let assetId = fromBase58String(assetIdString) | |
42 | + | let ownerKey = getTokenOwnerKey(assetId) | |
43 | + | let statusKey = getTokenStatusKey(assetId) | |
44 | + | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
45 | + | let status = getStringValue(statusKey) | |
46 | + | if (if ((founder == i.caller)) | |
47 | + | then true | |
48 | + | else if ((realOwner == i.caller)) | |
49 | + | then (status != StatusNa) | |
50 | + | else false) | |
51 | + | then [ScriptTransfer(i.caller, 1, assetId), StringEntry(getTokenOwnerKey(assetId), ""), StringEntry(getTokenStatusKey(assetId), StatusNa), IntegerEntry(getTokenPriceKey(assetId), 0)] | |
52 | + | else throw("Only owner and founder can pick it up") | |
53 | + | } | |
54 | + | ||
55 | + | ||
56 | + | ||
57 | + | @Callable(i) | |
58 | + | func setTokenInfo (assetIdString,isTradable,price) = { | |
59 | + | let assetId = fromBase58String(assetIdString) | |
60 | + | let ownerKey = getTokenOwnerKey(assetId) | |
61 | + | let statusKey = getTokenStatusKey(assetId) | |
62 | + | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
63 | + | let status = getStringValue(statusKey) | |
64 | + | if (if ((realOwner == i.caller)) | |
65 | + | then (status != StatusNa) | |
66 | + | else false) | |
67 | + | then [ScriptTransfer(i.caller, 1, assetId), StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), price)] | |
68 | + | else throw("Only owner can set token trade info") | |
69 | + | } | |
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | @Callable(i) | |
74 | + | func buy (assetIdString,isTradable,newPrice) = { | |
75 | + | let assetId = i.caller.bytes | |
76 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
77 | + | let callerAddress = Address(i.caller.bytes) | |
78 | + | let ownerKey = getTokenOwnerKey(assetId) | |
79 | + | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
80 | + | if (if ((size(i.payments) == 0)) | |
81 | + | then true | |
82 | + | else (i.caller == realOwner)) | |
83 | + | then throw("Payment must be attached and you should not be the asset owner") | |
84 | + | else { | |
85 | + | let pmt = i.payments[0] | |
86 | + | if (isDefined(pmt.assetId)) | |
87 | + | then throw("This function accepts WAVES tokens only") | |
88 | + | else { | |
89 | + | let currentPrice = getIntegerValue(getTokenPriceKey(assetId)) | |
90 | + | let onePercent = (currentPrice / 100) | |
91 | + | let totalSum = (onePercent * (100 + CommissionPercent)) | |
92 | + | let realCommission = (totalSum - currentPrice) | |
93 | + | if ((pmt.amount != totalSum)) | |
94 | + | then throw("Incorrect buy sum") | |
95 | + | else [ScriptTransfer(realOwner, currentPrice, unit), ScriptTransfer(founder, realCommission, unit), StringEntry(getTokenOwnerKey(assetId), callerAddressString), StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), newPrice)] | |
96 | + | } | |
97 | + | } | |
98 | + | } | |
99 | + | ||
100 | + | ||
101 | + | @Verifier(tx) | |
102 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
103 | + |
github/deemru/w8io/026f985 19.86 ms ◑