tx · DsLcwqCtckvqSCfr4BeG9ntsTXWq4ZvTQDSTT18qcXJ5 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves 2022.11.04 18:13 [2302531] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "DsLcwqCtckvqSCfr4BeG9ntsTXWq4ZvTQDSTT18qcXJ5", "fee": 1000000, "feeAssetId": null, "timestamp": 1667574837043, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "5oi1LhSR6WBsj5ejYfUThFzUZ8shcSB4gf5BzfTyV9qM1Y2BFeqSH7ZoEnnNxizFSw99cBNHB4ierBSiCuviQ2YH" ], "script": "base64:BgIRCAISBQoDCAgBEgQKAggBEgAFAAlzZXBhcmF0b3ICAV8ABGtCdXkCA2J1eQAFa1NlbGwCBHNlbGwABmtQcmljZQIFcHJpY2UBBWlzTmZ0AQdhc3NldElkBAckbWF0Y2gwCQDsBwEFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIFQXNzZXQEBXRva2VuBQckbWF0Y2gwAwMJAAACCAUFdG9rZW4IZGVjaW1hbHMAAAkAAAIIBQV0b2tlbghxdWFudGl0eQABBwkAAAIIBQV0b2tlbgpyZWlzc3VhYmxlBwcHAwFpAQhpc3N1ZU5mdAMEbmFtZQRtZXRhBXByaWNlBAhuZXdUb2tlbgkAwggFBQRuYW1lBQRtZXRhAAEAAAcEB2lzc3VlSWQJALgIAQUIbmV3VG9rZW4JAMwIAgUIbmV3VG9rZW4JAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyCAUIbmV3VG9rZW4IcXVhbnRpdHkFB2lzc3VlSWQJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICCQCsAgIFBmtQcmljZQUJc2VwYXJhd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EwNTgpAQkArAICCQCsAgIFBmtQcmljZQUJc2VwYXJhdG9yCQETdmFsdWVPckVycm9yTWVzc2FnZQIJANgEAQUGdG9rZW4wAh5UaGVyZSBpcyBubyBwcmljZSBmb3IgdGhpcyBORlQDCQEBIQEJAQVpc05mdAEFBnRva2VuMAkAAgECEFRva2VuIGlzIG5vdCBORlQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyCQBoAgkBDXBhcnNlSW50VmFsdWUBBQVwcmljZQUHYW1vdW50MAUEdW5pdAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgkApQgBCAUBaQZjYWxsZXIFCXNlcGFyYXRvcgUFa1NlbGwJAKwCAgkArAICCQDYBAEFBnRva2VuMAUJc2VwYXJhdG9yCQCkAwEFB2Ftb3VudDAFA25pbAALmbSL", "height": 2302531, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DsMjkGrzCzAT6gPs1qEqLYfAQJccqP8TeLQQkR9eXAPv Next: D76brpebbXP8T8kPFPHhFE1jCZMUPUnsWRc3kAR74LGH Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "_" | |
5 | 5 | ||
6 | - | let b = " | |
6 | + | let b = "buy" | |
7 | 7 | ||
8 | - | let c = " | |
8 | + | let c = "sell" | |
9 | 9 | ||
10 | - | let d = | |
10 | + | let d = "price" | |
11 | 11 | ||
12 | - | let e = 500 | |
13 | - | ||
14 | - | func f (g) = makeString([b, toBase58String(g)], a) | |
15 | - | ||
16 | - | ||
17 | - | func h (i,g) = makeString([i, toBase58String(g)], a) | |
18 | - | ||
19 | - | ||
20 | - | func j (k) = makeString([c, toBase58String(k)], a) | |
21 | - | ||
22 | - | ||
23 | - | func l (m,k) = makeString([m, toBase58String(k)], a) | |
24 | - | ||
25 | - | ||
26 | - | func n (o) = split(valueOrElse(getString(this, toString(o)), ""), a) | |
27 | - | ||
28 | - | ||
29 | - | func p (g) = split(valueOrElse(getString(this, f(g)), ""), a) | |
30 | - | ||
31 | - | ||
32 | - | func q (o) = valueOrElse(getString(this, toString(o)), "") | |
33 | - | ||
34 | - | ||
35 | - | func r (g) = valueOrElse(getString(this, f(g)), "") | |
36 | - | ||
37 | - | ||
38 | - | func s (o,i,g) = if ((i == "")) | |
39 | - | then StringEntry(toString(o), toBase58String(g)) | |
40 | - | else StringEntry(toString(o), h(i, g)) | |
41 | - | ||
42 | - | ||
43 | - | func t (g,m,k) = if ((m == "")) | |
44 | - | then StringEntry(f(g), toBase58String(k)) | |
45 | - | else StringEntry(f(g), l(m, k)) | |
46 | - | ||
47 | - | ||
48 | - | func u (v) = (size(n(v)) > d) | |
49 | - | ||
50 | - | ||
51 | - | func w (g) = (size(p(g)) > e) | |
52 | - | ||
53 | - | ||
54 | - | func x (k,v) = (assetBalance(v, k) == 1) | |
55 | - | ||
56 | - | ||
57 | - | func y (k) = isDefined(getString(this, j(k))) | |
58 | - | ||
59 | - | ||
60 | - | func z (o,g) = { | |
61 | - | let A = n(o) | |
62 | - | containsElement(A, toBase58String(g)) | |
12 | + | func e (f) = { | |
13 | + | let g = assetInfo(f) | |
14 | + | if ($isInstanceOf(g, "Asset")) | |
15 | + | then { | |
16 | + | let h = g | |
17 | + | if (if ((h.decimals == 0)) | |
18 | + | then (h.quantity == 1) | |
19 | + | else false) | |
20 | + | then (h.reissuable == false) | |
21 | + | else false | |
22 | + | } | |
23 | + | else false | |
63 | 24 | } | |
64 | 25 | ||
65 | 26 | ||
66 | - | func B (k,v) = if (!(x(k, v))) | |
67 | - | then throw("Caller is not owner of nft") | |
68 | - | else if (y(k)) | |
69 | - | then throw("Content already setted for this nft") | |
70 | - | else unit | |
71 | - | ||
72 | - | ||
73 | - | @Callable(C) | |
74 | - | func addCollection () = if (u(C.caller)) | |
75 | - | then throw("You reached collections limit") | |
76 | - | else [s(C.caller, q(C.caller), C.transactionId)] | |
27 | + | @Callable(i) | |
28 | + | func issueNft (j,k,l) = { | |
29 | + | let m = Issue(j, k, 1, 0, false) | |
30 | + | let n = calculateAssetId(m) | |
31 | + | [m, ScriptTransfer(i.caller, m.quantity, n), StringEntry(((d + a) + toBase58String(n)), toString(l))] | |
32 | + | } | |
77 | 33 | ||
78 | 34 | ||
79 | 35 | ||
80 | - | @Callable(C) | |
81 | - | func mint (g,D,E) = if (!(z(C.caller, g))) | |
82 | - | then throw("Wrong collection or caller ID") | |
83 | - | else if (w(g)) | |
84 | - | then throw("You reached nfts limit in this collection") | |
85 | - | else { | |
86 | - | let F = Issue(D, E, 1, 0, false) | |
87 | - | let G = calculateAssetId(F) | |
88 | - | [F, ScriptTransfer(C.caller, F.quantity, G), t(g, r(g), G)] | |
89 | - | } | |
36 | + | @Callable(i) | |
37 | + | func buyNFT (o,p) = { | |
38 | + | let q = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
39 | + | let r = q._1 | |
40 | + | let s = q._2 | |
41 | + | let l = valueOrErrorMessage(getStringValue(((d + a) + o)), "There is no price for this NFT") | |
42 | + | if ((i.payments[0].assetId != unit)) | |
43 | + | then throw("Pay in waves") | |
44 | + | else if ((parseIntValue(l) > (s * p))) | |
45 | + | then throw("Invalid payment attached") | |
46 | + | else [ScriptTransfer(i.caller, p, fromBase58String(o)), StringEntry(((toString(i.caller) + a) + b), ((o + a) + toString(p)))] | |
47 | + | } | |
90 | 48 | ||
91 | 49 | ||
92 | 50 | ||
93 | - | @Callable(C) | |
94 | - | func setContent (k,H) = valueOrElse(B(k, C.caller), [StringEntry(j(k), H)]) | |
51 | + | @Callable(i) | |
52 | + | func sellNFT () = { | |
53 | + | let t = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
54 | + | let r = t._1 | |
55 | + | let s = t._2 | |
56 | + | let l = getStringValue(((d + a) + valueOrErrorMessage(toBase58String(r), "There is no price for this NFT"))) | |
57 | + | if (!(e(r))) | |
58 | + | then throw("Token is not NFT") | |
59 | + | else [ScriptTransfer(i.caller, (parseIntValue(l) * s), unit), StringEntry(((toString(i.caller) + a) + c), ((toBase58String(r) + a) + toString(s)))] | |
60 | + | } | |
95 | 61 | ||
96 | 62 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "_" | |
5 | 5 | ||
6 | - | let b = " | |
6 | + | let b = "buy" | |
7 | 7 | ||
8 | - | let c = " | |
8 | + | let c = "sell" | |
9 | 9 | ||
10 | - | let d = | |
10 | + | let d = "price" | |
11 | 11 | ||
12 | - | let e = 500 | |
13 | - | ||
14 | - | func f (g) = makeString([b, toBase58String(g)], a) | |
15 | - | ||
16 | - | ||
17 | - | func h (i,g) = makeString([i, toBase58String(g)], a) | |
18 | - | ||
19 | - | ||
20 | - | func j (k) = makeString([c, toBase58String(k)], a) | |
21 | - | ||
22 | - | ||
23 | - | func l (m,k) = makeString([m, toBase58String(k)], a) | |
24 | - | ||
25 | - | ||
26 | - | func n (o) = split(valueOrElse(getString(this, toString(o)), ""), a) | |
27 | - | ||
28 | - | ||
29 | - | func p (g) = split(valueOrElse(getString(this, f(g)), ""), a) | |
30 | - | ||
31 | - | ||
32 | - | func q (o) = valueOrElse(getString(this, toString(o)), "") | |
33 | - | ||
34 | - | ||
35 | - | func r (g) = valueOrElse(getString(this, f(g)), "") | |
36 | - | ||
37 | - | ||
38 | - | func s (o,i,g) = if ((i == "")) | |
39 | - | then StringEntry(toString(o), toBase58String(g)) | |
40 | - | else StringEntry(toString(o), h(i, g)) | |
41 | - | ||
42 | - | ||
43 | - | func t (g,m,k) = if ((m == "")) | |
44 | - | then StringEntry(f(g), toBase58String(k)) | |
45 | - | else StringEntry(f(g), l(m, k)) | |
46 | - | ||
47 | - | ||
48 | - | func u (v) = (size(n(v)) > d) | |
49 | - | ||
50 | - | ||
51 | - | func w (g) = (size(p(g)) > e) | |
52 | - | ||
53 | - | ||
54 | - | func x (k,v) = (assetBalance(v, k) == 1) | |
55 | - | ||
56 | - | ||
57 | - | func y (k) = isDefined(getString(this, j(k))) | |
58 | - | ||
59 | - | ||
60 | - | func z (o,g) = { | |
61 | - | let A = n(o) | |
62 | - | containsElement(A, toBase58String(g)) | |
12 | + | func e (f) = { | |
13 | + | let g = assetInfo(f) | |
14 | + | if ($isInstanceOf(g, "Asset")) | |
15 | + | then { | |
16 | + | let h = g | |
17 | + | if (if ((h.decimals == 0)) | |
18 | + | then (h.quantity == 1) | |
19 | + | else false) | |
20 | + | then (h.reissuable == false) | |
21 | + | else false | |
22 | + | } | |
23 | + | else false | |
63 | 24 | } | |
64 | 25 | ||
65 | 26 | ||
66 | - | func B (k,v) = if (!(x(k, v))) | |
67 | - | then throw("Caller is not owner of nft") | |
68 | - | else if (y(k)) | |
69 | - | then throw("Content already setted for this nft") | |
70 | - | else unit | |
71 | - | ||
72 | - | ||
73 | - | @Callable(C) | |
74 | - | func addCollection () = if (u(C.caller)) | |
75 | - | then throw("You reached collections limit") | |
76 | - | else [s(C.caller, q(C.caller), C.transactionId)] | |
27 | + | @Callable(i) | |
28 | + | func issueNft (j,k,l) = { | |
29 | + | let m = Issue(j, k, 1, 0, false) | |
30 | + | let n = calculateAssetId(m) | |
31 | + | [m, ScriptTransfer(i.caller, m.quantity, n), StringEntry(((d + a) + toBase58String(n)), toString(l))] | |
32 | + | } | |
77 | 33 | ||
78 | 34 | ||
79 | 35 | ||
80 | - | @Callable(C) | |
81 | - | func mint (g,D,E) = if (!(z(C.caller, g))) | |
82 | - | then throw("Wrong collection or caller ID") | |
83 | - | else if (w(g)) | |
84 | - | then throw("You reached nfts limit in this collection") | |
85 | - | else { | |
86 | - | let F = Issue(D, E, 1, 0, false) | |
87 | - | let G = calculateAssetId(F) | |
88 | - | [F, ScriptTransfer(C.caller, F.quantity, G), t(g, r(g), G)] | |
89 | - | } | |
36 | + | @Callable(i) | |
37 | + | func buyNFT (o,p) = { | |
38 | + | let q = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
39 | + | let r = q._1 | |
40 | + | let s = q._2 | |
41 | + | let l = valueOrErrorMessage(getStringValue(((d + a) + o)), "There is no price for this NFT") | |
42 | + | if ((i.payments[0].assetId != unit)) | |
43 | + | then throw("Pay in waves") | |
44 | + | else if ((parseIntValue(l) > (s * p))) | |
45 | + | then throw("Invalid payment attached") | |
46 | + | else [ScriptTransfer(i.caller, p, fromBase58String(o)), StringEntry(((toString(i.caller) + a) + b), ((o + a) + toString(p)))] | |
47 | + | } | |
90 | 48 | ||
91 | 49 | ||
92 | 50 | ||
93 | - | @Callable(C) | |
94 | - | func setContent (k,H) = valueOrElse(B(k, C.caller), [StringEntry(j(k), H)]) | |
51 | + | @Callable(i) | |
52 | + | func sellNFT () = { | |
53 | + | let t = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
54 | + | let r = t._1 | |
55 | + | let s = t._2 | |
56 | + | let l = getStringValue(((d + a) + valueOrErrorMessage(toBase58String(r), "There is no price for this NFT"))) | |
57 | + | if (!(e(r))) | |
58 | + | then throw("Token is not NFT") | |
59 | + | else [ScriptTransfer(i.caller, (parseIntValue(l) * s), unit), StringEntry(((toString(i.caller) + a) + c), ((toBase58String(r) + a) + toString(s)))] | |
60 | + | } | |
95 | 61 | ||
96 | 62 |
github/deemru/w8io/026f985 26.26 ms ◑