tx · BUDhUPsLcZE36WbdRj2Rtvj2KUkwhXjZsDTUpqSmbFJv 3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja: -0.01000010 Waves 2021.07.21 16:14 [1623429] smart account 3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja > SELF 0.00000000 Waves
{ "type": 13, "id": "BUDhUPsLcZE36WbdRj2Rtvj2KUkwhXjZsDTUpqSmbFJv", "fee": 1000010, "feeAssetId": null, "timestamp": 1626873285853, "version": 2, "chainId": 84, "sender": "3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja", "senderPublicKey": "7Cy4wXHvgCRHP6MMhu9tTdayLHr9P9Dc342DVcCoCPzm", "proofs": [ "67CUATPnDEsZBVTmk2hEAupdsMVXbaBR4PLsy8cTCatYYwoFWF5tvVBSwRenFKnEEnB1QcGSsBFyzi8CSHHUByq6" ], "script": "base64:AAIFAAAAAAAAAAkIAhIAEgMKAQEAAAABAAAAAAR3RVVSAQAAACBRgM2l49nKLjfHvaSg2e7mORayjPZpt1hF5HDPqsnD2gAAAAIAAAABaQEAAAAHZGVwb3NpdAAAAAAEAAAAA3BtdAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAMJAQAAAAIhPQAAAAIIBQAAAANwbXQAAAAHYXNzZXRJZAUAAAAEd0VVUgkAAAIAAAABAgAAADV3RVVSIC0gJzZWOXdQcUIzZ01UcWE4MjlYVmt4anBSbnhyTUdaTWh4UjQ0MUpDMmttZmgzJwQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAQAAAAJbmV3QW1vdW50CQAAZAAAAAIFAAAADWN1cnJlbnRBbW91bnQIBQAAAANwbXQAAAAGYW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAApjdXJyZW50S2V5BQAAAAluZXdBbW91bnQFAAAAA25pbAAAAAFpAQAAAAd3aXRkcmF3AAAAAQAAAAZhbW91bnQEAAAACmN1cnJlbnRLZXkJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAApjdXJyZW50S2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAEAAAACW5ld0Ftb3VudAkAAGUAAAACBQAAAA1jdXJyZW50QW1vdW50BQAAAAZhbW91bnQDCQAAZgAAAAIAAAAAAAAAAAAFAAAABmFtb3VudAkAAAIAAAABAgAAAB9jYW4ndCB3aXRoZHJhdyBuZWdhdGl2ZXMgYW1vdW50AwkAAGYAAAACAAAAAAAAAAAABQAAAAluZXdBbW91bnQJAAACAAAAAQIAAAASTm90IGVub3VnaCBiYWxhbmNlCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAApjdXJyZW50S2V5BQAAAAluZXdBbW91bnQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHdFVVIFAAAAA25pbAAAAACfw6mx", "height": 1623429, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7Lfcqsp3pnmuFur37TzNQydAqcHybAbQi9hDGHxP4JKT Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let a = | |
4 | + | let a = base58'6V9wPqB3gMTqa829XVkxjpRnxrMGZMhxR441JC2kmfh3' | |
5 | 5 | ||
6 | - | func b (c) = { | |
7 | - | let d = { | |
8 | - | let e = getInteger(this, c) | |
9 | - | if ($isInstanceOf(e, "Int")) | |
10 | - | then { | |
11 | - | let f = e | |
12 | - | f | |
6 | + | @Callable(b) | |
7 | + | func deposit () = { | |
8 | + | let c = b.payments[0] | |
9 | + | if ((c.assetId != a)) | |
10 | + | then throw("wEUR - '6V9wPqB3gMTqa829XVkxjpRnxrMGZMhxR441JC2kmfh3'") | |
11 | + | else { | |
12 | + | let d = toBase58String(b.caller.bytes) | |
13 | + | let e = { | |
14 | + | let f = getInteger(this, d) | |
15 | + | if ($isInstanceOf(f, "Int")) | |
16 | + | then { | |
17 | + | let g = f | |
18 | + | g | |
19 | + | } | |
20 | + | else 0 | |
13 | 21 | } | |
14 | - | else 0 | |
15 | - | } | |
16 | - | d | |
17 | - | } | |
18 | - | ||
19 | - | ||
20 | - | func g (c) = { | |
21 | - | let h = { | |
22 | - | let e = getString(this, c) | |
23 | - | if ($isInstanceOf(e, "String")) | |
24 | - | then { | |
25 | - | let f = e | |
26 | - | f | |
27 | - | } | |
28 | - | else a | |
29 | - | } | |
30 | - | h | |
31 | - | } | |
32 | - | ||
33 | - | ||
34 | - | func i (j) = (j + "_price") | |
35 | - | ||
36 | - | ||
37 | - | func k (j) = b(i(j)) | |
38 | - | ||
39 | - | ||
40 | - | func l (m,j) = (((j + "_") + m) + "_cnt") | |
41 | - | ||
42 | - | ||
43 | - | func n (m,j) = b(l(m, j)) | |
44 | - | ||
45 | - | ||
46 | - | func o (p,q) = ("item_" + toBase58String(sha256(toBytes((p + q))))) | |
47 | - | ||
48 | - | ||
49 | - | func r (j) = (j + "_data") | |
50 | - | ||
51 | - | ||
52 | - | func s (j) = (j + "_data") | |
53 | - | ||
54 | - | ||
55 | - | func t (j) = g(s(j)) | |
56 | - | ||
57 | - | ||
58 | - | func u (v) = (v + "_balance") | |
59 | - | ||
60 | - | ||
61 | - | func w (v) = b(u(v)) | |
62 | - | ||
63 | - | ||
64 | - | @Callable(x) | |
65 | - | func addItem (q,y,z) = { | |
66 | - | let A = toBase58String(x.caller.bytes) | |
67 | - | let j = o(A, q) | |
68 | - | if ((0 >= y)) | |
69 | - | then throw("purchase amount cannot be less than item price") | |
70 | - | else if ((t(j) != a)) | |
71 | - | then throw("an item is already exist") | |
72 | - | else [StringEntry(s(j), A), IntegerEntry(i(j), y), StringEntry(r(j), z)] | |
73 | - | } | |
74 | - | ||
75 | - | ||
76 | - | ||
77 | - | @Callable(x) | |
78 | - | func purchase (j) = { | |
79 | - | let B = x.payments[0] | |
80 | - | if (isDefined(B.assetId)) | |
81 | - | then throw("WAVES token only at the moment") | |
82 | - | else { | |
83 | - | let C = toBase58String(x.caller.bytes) | |
84 | - | let y = k(j) | |
85 | - | let D = t(j) | |
86 | - | if ((y > B.amount)) | |
87 | - | then throw("purchase amunt cannot be less than item price") | |
88 | - | else if ((B.amount > y)) | |
89 | - | then throw("purchase amount cannot be higher than item price") | |
90 | - | else if ((D == a)) | |
91 | - | then throw("Supplier address doesn't exist") | |
92 | - | else [IntegerEntry(l(C, j), (n(C, j) + 1)), IntegerEntry(u(D), (w(D) + B.amount))] | |
22 | + | let h = (e + c.amount) | |
23 | + | [IntegerEntry(d, h)] | |
93 | 24 | } | |
94 | 25 | } | |
95 | 26 | ||
96 | 27 | ||
97 | 28 | ||
98 | - | @Callable(x) | |
99 | - | func withdraw () = { | |
100 | - | let A = toBase58String(x.caller.bytes) | |
101 | - | let E = w(A) | |
102 | - | if ((0 >= E)) | |
103 | - | then throw("za mało środków") | |
104 | - | else [IntegerEntry(u(A), 0), ScriptTransfer(addressFromStringValue(A), E, unit)] | |
29 | + | @Callable(b) | |
30 | + | func witdraw (i) = { | |
31 | + | let d = toBase58String(b.caller.bytes) | |
32 | + | let e = { | |
33 | + | let f = getInteger(this, d) | |
34 | + | if ($isInstanceOf(f, "Int")) | |
35 | + | then { | |
36 | + | let g = f | |
37 | + | g | |
38 | + | } | |
39 | + | else 0 | |
40 | + | } | |
41 | + | let h = (e - i) | |
42 | + | if ((0 > i)) | |
43 | + | then throw("can't withdraw negatives amount") | |
44 | + | else if ((0 > h)) | |
45 | + | then throw("Not enough balance") | |
46 | + | else [IntegerEntry(d, h), ScriptTransfer(b.caller, i, a)] | |
105 | 47 | } | |
106 | 48 | ||
107 | 49 |
github/deemru/w8io/026f985 27.19 ms ◑