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