tx · 7sDWF6wtE9jAVLFfjAGHZDH8dLpET9BMdkGQWB5b9UZJ 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq: -0.01400000 Waves 2019.06.22 21:03 [553587] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves
{ "type": 13, "id": "7sDWF6wtE9jAVLFfjAGHZDH8dLpET9BMdkGQWB5b9UZJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1561226673118, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "nwNi1PvHRc7V8bK7oRGyrYnfffQGB9JMJxLFsu1A4g9RkQJyCPFwP6aYuPeBXhxYmuP7nRicxMr3MrhGRPzEUJ4" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARpd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2V5QmFsYW5jZVN1cHBsaWVyAAAAAQUAAAAHc3VwcGFkZAAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAHc3VwcGFkZAUAAAADYmFsBQAAAAR1bml0BQAAAANuaWwAAAAACxv0qg==", "chainId": 84, "height": 553587, "spentComplexity": 0 } View: original | compacted Prev: CWrLUufHmLNSbDeiEJXyBgDDFcBNkrBwR9jRnzUmkLhB Next: HmBzj946MzeuYTqBQTjWtVqvSPJ1gvCdHhuwFRTqpsaS Diff:
Old | New | Differences | |
---|---|---|---|
86 | 86 | } | |
87 | 87 | ||
88 | 88 | ||
89 | + | ||
90 | + | @Callable(i) | |
91 | + | func withdraw () = { | |
92 | + | let suppadd = toBase58String(i.caller.bytes) | |
93 | + | let bal = getValueBalanceSupplier(suppadd) | |
94 | + | if ((0 >= bal)) | |
95 | + | then throw("Insufficient Balance") | |
96 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(suppadd), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppadd), bal, unit)])) | |
97 | + | } | |
98 | + | ||
99 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getKeyItemPrice (item) = (item + "_price") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func getNumberByKey (key) = { | |
10 | 10 | let num = match getInteger(this, key) { | |
11 | 11 | case a: Int => | |
12 | 12 | a | |
13 | 13 | case _ => | |
14 | 14 | 0 | |
15 | 15 | } | |
16 | 16 | num | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getStrByKey (key) = { | |
21 | 21 | let str = match getString(this, key) { | |
22 | 22 | case a: String => | |
23 | 23 | a | |
24 | 24 | case _ => | |
25 | 25 | NONE | |
26 | 26 | } | |
27 | 27 | str | |
28 | 28 | } | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func additem (title,price,data) = { | |
60 | 60 | let suppad = toBase58String(i.caller.bytes) | |
61 | 61 | let item = getKeyItem(suppad, title) | |
62 | 62 | if ((0 >= price)) | |
63 | 63 | then throw("purchase amount cannot be less than 0 or 0") | |
64 | 64 | else if ((getValueItemSupplier(item) != NONE)) | |
65 | 65 | then throw("an item already exists") | |
66 | 66 | else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
67 | 67 | } | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func purchase (item) = { | |
73 | 73 | let pmt = extract(i.payment) | |
74 | 74 | if (isDefined(pmt.assetId)) | |
75 | 75 | then throw("Can use Waves only at the moment") | |
76 | 76 | else { | |
77 | 77 | let customerAddress = toBase58String(i.caller.bytes) | |
78 | 78 | let price = getValueItemPrice(item) | |
79 | 79 | let supadd = getValueItemSupplier(item) | |
80 | 80 | if ((price > pmt.amount)) | |
81 | 81 | then throw("purchase amount cannot be less than item price ") | |
82 | 82 | else if ((pmt.amount > price)) | |
83 | 83 | then throw("purchase amount cannot be higher than item price") | |
84 | 84 | else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, item), (getValueUserItemCounter(customerAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supadd), (getValueBalanceSupplier(supadd) + pmt.amount))]) | |
85 | 85 | } | |
86 | 86 | } | |
87 | 87 | ||
88 | 88 | ||
89 | + | ||
90 | + | @Callable(i) | |
91 | + | func withdraw () = { | |
92 | + | let suppadd = toBase58String(i.caller.bytes) | |
93 | + | let bal = getValueBalanceSupplier(suppadd) | |
94 | + | if ((0 >= bal)) | |
95 | + | then throw("Insufficient Balance") | |
96 | + | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(suppadd), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppadd), bal, unit)])) | |
97 | + | } | |
98 | + | ||
99 | + |
github/deemru/w8io/026f985 24.59 ms ◑