tx · JC2J2Zg3MfDDUpdDn7JszMujNB7G3peGGjuCLZEe2qQ2 3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq: -0.01000000 Waves 2022.11.22 08:04 [2327886] smart account 3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq > SELF 0.00000000 Waves
{ "type": 13, "id": "JC2J2Zg3MfDDUpdDn7JszMujNB7G3peGGjuCLZEe2qQ2", "fee": 1000000, "feeAssetId": null, "timestamp": 1669093479294, "version": 2, "chainId": 84, "sender": "3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq", "senderPublicKey": "H6UqxUDcJamDRg1uykVcWMn4zhAMTV7i1nfPq1moLWmJ", "proofs": [ "x4gN4hsg8HJX5G1JTbQAFHz8vqrvZ6yHb5pzVTuvapP9MhTJqCPDaYavvJUjV7GxzSq57VxDuUywv46Sc64auGa" ], "script": "base64:BgIgCAISCwoJCAgICAgBCAgIEgMKAQESAwoBCBIDCgEIEgAGAAlzZXBhcmF0b3ICAV8ABGtCdXkCA2J1eQAFa1NlbGwCBHNlbGwABmtQcmljZQIFcHJpY2UACWRBcHBPd25lcgEaAVRKuE9s3sLak+30julKNvjVT3+V1VVbXaABBWlzTmZ0AQdhc3NldElkBAckbWF0Y2gwCQDsBwEFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIFQXNzZXQEBXRva2VuBQckbWF0Y2gwAwMJAAACCAUFdG9rZW4IZGVjaW1hbHMAAAkAAAIIBQV0b2tlbghxdWFudGl0eQABBwkAAAIIBQV0b2tlbgpyZWlzc3VhYmxlBwcHBQFpAQhpc3N1ZU5mdAkIbmZ0X25hbWUJbmZ0X293bmVyD25mdF9kQXBwQWRkcmVzcwhuZnRfdHlwZQhuZnRfdGFncxFuZnRfc2VsbGluZ19wcmljZQ9uZnRfZGVzY3JpcHRpb24KbmZ0X29uU2VsbAluZnRfaW1hZ2UEBHR4SWQIBQFpDXRyYW5zYWN0aW9uSWQEB2NyZWF0b3IJANgEAQg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8UTmy6aw8tCw352T7Cx6sG5FjC6JHqex5877hsSWhvK3 Next: 6HCt4U7tmp9zB7tqJ3ZafukEeanwfLbPvtHRSbsUSEyz Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | let issueMetadata = (((((((("{creator: " + creator) + ",") + ("creator_name: " + creator_name)) + ",") + ("description: " + nft_description)) + ",") + ("nft_art_id" + toBase58String(txId))) + "}") | |
32 | 32 | let newToken = Issue(nft_name, issueMetadata, 1, 0, false) | |
33 | 33 | let issueId = calculateAssetId(newToken) | |
34 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_image"), nft_image), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), issueMetadata), StringEntry(((toBase58String(i.caller.bytes) + separator) + "nft_owner"), creator), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] | |
34 | + | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_image"), nft_image), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), issueMetadata), StringEntry(((toBase58String(i.caller.bytes) + separator) + "nft_owner"), creator), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | 6 | let kBuy = "buy" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | 10 | let kPrice = "price" | |
11 | 11 | ||
12 | 12 | let dAppOwner = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq' | |
13 | 13 | ||
14 | 14 | func isNft (assetId) = match assetInfo(assetId) { | |
15 | 15 | case token: Asset => | |
16 | 16 | if (if ((token.decimals == 0)) | |
17 | 17 | then (token.quantity == 1) | |
18 | 18 | else false) | |
19 | 19 | then (token.reissuable == false) | |
20 | 20 | else false | |
21 | 21 | case _ => | |
22 | 22 | false | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | @Callable(i) | |
27 | 27 | func issueNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_image) = { | |
28 | 28 | let txId = i.transactionId | |
29 | 29 | let creator = toBase58String(i.caller.bytes) | |
30 | 30 | let creator_name = nft_owner | |
31 | 31 | let issueMetadata = (((((((("{creator: " + creator) + ",") + ("creator_name: " + creator_name)) + ",") + ("description: " + nft_description)) + ",") + ("nft_art_id" + toBase58String(txId))) + "}") | |
32 | 32 | let newToken = Issue(nft_name, issueMetadata, 1, 0, false) | |
33 | 33 | let issueId = calculateAssetId(newToken) | |
34 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_image"), nft_image), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), issueMetadata), StringEntry(((toBase58String(i.caller.bytes) + separator) + "nft_owner"), creator), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] | |
34 | + | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_image"), nft_image), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), issueMetadata), StringEntry(((toBase58String(i.caller.bytes) + separator) + "nft_owner"), creator), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | 39 | @Callable(i) | |
40 | 40 | func sellNFT (price) = { | |
41 | 41 | let token = i.payments[0].assetId | |
42 | 42 | let assetid = value(i.payments[0].assetId) | |
43 | 43 | let amount0 = value(i.payments[0].amount) | |
44 | 44 | if (!(isNft(assetid))) | |
45 | 45 | then throw("Token is not NFT") | |
46 | 46 | else [StringEntry((toBase58String(assetid) + "_owner"), toString(i.caller)), StringEntry((toBase58String(assetid) + "_nft_selling_price"), toString(price)), StringEntry((toBase58String(assetid) + "_onsell"), "true"), StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(assetid) + separator) + toString(amount0)))] | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | ||
51 | 51 | @Callable(i) | |
52 | 52 | func buyNFTTesting (nftID) = { | |
53 | 53 | let caller = toBase64String(i.caller.bytes) | |
54 | 54 | let assetId = fromBase58String(nftID) | |
55 | 55 | let amount = value(i.payments[0].amount) | |
56 | 56 | let nftOwner = getStringValue((toBase58String(assetId) + "_owner")) | |
57 | 57 | let price = match getString(this, (toBase58String(assetId) + "_nft_selling_price")) { | |
58 | 58 | case a: String => | |
59 | 59 | a | |
60 | 60 | case _ => | |
61 | 61 | "0" | |
62 | 62 | } | |
63 | 63 | let issell = match getString(this, (toBase58String(assetId) + "_onsell")) { | |
64 | 64 | case a: String => | |
65 | 65 | a | |
66 | 66 | case _ => | |
67 | 67 | "false" | |
68 | 68 | } | |
69 | 69 | if ((i.payments[0].assetId != unit)) | |
70 | 70 | then throw("Pay in waves") | |
71 | 71 | else if (if ((parseIntValue(price) != amount)) | |
72 | 72 | then (parseIntValue(price) == 0) | |
73 | 73 | else false) | |
74 | 74 | then throw("Invalid payment") | |
75 | 75 | else if ((caller == nftOwner)) | |
76 | 76 | then throw("NFT owner will not able to buy this") | |
77 | 77 | else if ((caller == toBase58String(dAppOwner))) | |
78 | 78 | then throw("You are not eligible due to owner account of app") | |
79 | 79 | else if ((issell != "true")) | |
80 | 80 | then throw("Not on sell") | |
81 | 81 | else [StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), StringEntry((((toString(i.caller) + separator) + kBuy) + "_from"), nftOwner), DeleteEntry((toBase58String(assetId) + "_owner")), DeleteEntry((toBase58String(assetId) + "_onsell")), ScriptTransfer(addressFromStringValue(nftOwner), parseIntValue(price), unit), ScriptTransfer(i.caller, 1, assetId)] | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | 86 | @Callable(i) | |
87 | 87 | func buyNFT (nftID) = { | |
88 | 88 | let assetId = fromBase58String(nftID) | |
89 | 89 | let amount = value(i.payments[0].amount) | |
90 | 90 | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
91 | 91 | let issell = match getString(this, (toBase58String(assetId) + "_onsell")) { | |
92 | 92 | case a: String => | |
93 | 93 | a | |
94 | 94 | case _ => | |
95 | 95 | "false" | |
96 | 96 | } | |
97 | 97 | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
98 | 98 | if ((i.payments[0].assetId != unit)) | |
99 | 99 | then throw("Pay in waves") | |
100 | 100 | else if ((parseIntValue(price) > amount)) | |
101 | 101 | then throw("Invalid payment") | |
102 | 102 | else if ((issell != "true")) | |
103 | 103 | then throw("Not on sell") | |
104 | 104 | else [StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((toBase58String(assetId) + "_owner")), DeleteEntry((toBase58String(assetId) + "_onsell")), ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit)] | |
105 | 105 | } | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | ||
109 | 109 | @Callable(i) | |
110 | 110 | func deleteNFT () = { | |
111 | 111 | let token0 = i.payments[0].assetId | |
112 | 112 | [StringEntry(("delete_" + toBase58String(value(i.payments[0].assetId))), "token burn"), Burn(value(token0), 1)] | |
113 | 113 | } | |
114 | 114 | ||
115 | 115 |
github/deemru/w8io/026f985 49.79 ms ◑