tx · ERF1sLvsJ76NijdJw7hbdWw7drbvMxX8NLzhddCfdzDR 3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq: -0.01000000 Waves 2022.11.22 12:33 [2328150] smart account 3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq > SELF 0.00000000 Waves
{ "type": 13, "id": "ERF1sLvsJ76NijdJw7hbdWw7drbvMxX8NLzhddCfdzDR", "fee": 1000000, "feeAssetId": null, "timestamp": 1669109681583, "version": 2, "chainId": 84, "sender": "3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq", "senderPublicKey": "H6UqxUDcJamDRg1uykVcWMn4zhAMTV7i1nfPq1moLWmJ", "proofs": [ "2eL1McSEdsqnZFaW1Ak4zS6TqyKySN1UnX7w7xep2mPZoVZyYV7HgRV3HJLNR1SMqfAhszR21hYYcsVYa7hnR4CB" ], "script": "base64:BgIfCAISCwoJCAgICAgBCAgIEgQKAggIEgMKAQgSAwoBAQUACXNlcGFyYXRvcgIBXwAEa0J1eQIDYnV5AAVrU2VsbAIEc2VsbAAGa1ByaWNlAgVwcmljZQEFaXNOZnQBB2Fzc2V0SWQEByRtYXRjaDAJAOwHAQUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgVBc3NldAQFdG9rZW4FByRtYXRjaDADAwkAAAIIBQV0b2tlbghkZWNpbWFscwAACQAAAggFBXRva2VuCHF1YW50aXR5AAEHCQAAAggFBXRva2VuCnJlaXNzdWFibGUHBwcEAWkBCGlzc3VlTmZ0CQhuZnRfbmFtZQluZnRfb3duZXIPbmZ0X2RBcHBBZGRyZXNzCG5mdF90eXBlCG5mdF90YWdzEW5mdF9zZWxsaW5nX3ByaWNlD25mdF9kZXNjcmlwdGlvbgpuZnRfb25TZWxsCG5mdF9kYXRhBAhuZXdUb2tlbgkAwggFBQhuZnRfbmFtZQUPbmZ0X2Rlc2NyaXB0aW9uAAEAAAcEBHR4SWQIBQFpDXRyYW5zYWN0aW9uSWQEB2lzc3VlSWQ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ICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAkBBXZhbHVlAQgJAJEDAggFAWkIcGF5bWVudHMAAAZhbW91bnQEBnRva2VuMAgFCyR0MDI0NjQyNTQ5Al8xBAdhbW91bnQwCAULJHQwMjQ2NDI1NDkCXzIEB2Fzc2V0aWQJAQV2YWx1ZQEICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAMJAQEhAQkBBWlzTmZ0AQUGdG9rZW4wCQACAQIQVG9rZW4gaXMgbm90IE5GVAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJANgEAQUHYXNzZXRpZAIGX293bmVyCQClCAEIBQFpBmNhbGxlcgkAzAgCCQEMSW50ZWdlckVudHJ5AgkArAICCQDYBAEFB2Fzc2V0aWQCEl9uZnRfc2VsbGluZ19wcmljZQUFcHJpY2UJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICCQDYBAEFB2Fzc2V0aWQCB19vbnNlbGwCBHRydWUJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgkArAICBQZrUHJpY2UFCXNlcGFyYXRvcgkA2AQBCQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAAB2Fzc2V0SWQFBXByaWNlCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICCQClCAEIBQFpBmNhbGxlcgUJc2VwYXJhdG9yBQVrU2VsbAkArAICCQCsAgIJANgEAQUGdG9rZW4wBQlzZXBhcmF0b3IJAKQDAQUHYW1vdW50MAUDbmlsAOz5KBM=", "height": 2328150, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BwpMAdzDApyQH2yPfTvRS5kxYPkPCRobxq7pV1rJ6rDQ Next: 7eCD58kwqKzy6gSvUTpNBtTXN7LZCcQWcuytDT3H7LqX Diff:
Old | New | Differences | |
---|---|---|---|
44 | 44 | func buyNFT (nftID) = { | |
45 | 45 | let assetId = fromBase58String(nftID) | |
46 | 46 | let amount = value(i.payments[0].amount) | |
47 | - | let price = valueOrErrorMessage( | |
47 | + | let price = valueOrErrorMessage(getInteger(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
48 | 48 | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
49 | 49 | if ((i.payments[0].assetId != unit)) | |
50 | 50 | then throw("Pay in waves") | |
51 | - | else if (( | |
51 | + | else if ((price > amount)) | |
52 | 52 | then throw("Invalid payment") | |
53 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), | |
53 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), price, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
54 | 54 | } | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func sellNFT (price) = { | |
60 | - | let $ | |
61 | - | let token0 = $ | |
62 | - | let amount0 = $ | |
60 | + | let $t024642549 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
61 | + | let token0 = $t024642549._1 | |
62 | + | let amount0 = $t024642549._2 | |
63 | 63 | let assetid = value(i.payments[0].assetId) | |
64 | 64 | if (!(isNft(token0))) | |
65 | 65 | then throw("Token is not NFT") |
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 | func isNft (assetId) = match assetInfo(assetId) { | |
13 | 13 | case token: Asset => | |
14 | 14 | if (if ((token.decimals == 0)) | |
15 | 15 | then (token.quantity == 1) | |
16 | 16 | else false) | |
17 | 17 | then (token.reissuable == false) | |
18 | 18 | else false | |
19 | 19 | case _ => | |
20 | 20 | false | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | @Callable(i) | |
25 | 25 | func issueNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
26 | 26 | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
27 | 27 | let txId = i.transactionId | |
28 | 28 | let issueId = calculateAssetId(newToken) | |
29 | 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))] | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | 34 | @Callable(i) | |
35 | 35 | func createNFT (name,meta) = { | |
36 | 36 | let newToken = Issue(name, meta, 1, 0, false) | |
37 | 37 | let issueId = calculateAssetId(newToken) | |
38 | 38 | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | ||
43 | 43 | @Callable(i) | |
44 | 44 | func buyNFT (nftID) = { | |
45 | 45 | let assetId = fromBase58String(nftID) | |
46 | 46 | let amount = value(i.payments[0].amount) | |
47 | - | let price = valueOrErrorMessage( | |
47 | + | let price = valueOrErrorMessage(getInteger(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
48 | 48 | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
49 | 49 | if ((i.payments[0].assetId != unit)) | |
50 | 50 | then throw("Pay in waves") | |
51 | - | else if (( | |
51 | + | else if ((price > amount)) | |
52 | 52 | then throw("Invalid payment") | |
53 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), | |
53 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), price, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
54 | 54 | } | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func sellNFT (price) = { | |
60 | - | let $ | |
61 | - | let token0 = $ | |
62 | - | let amount0 = $ | |
60 | + | let $t024642549 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
61 | + | let token0 = $t024642549._1 | |
62 | + | let amount0 = $t024642549._2 | |
63 | 63 | let assetid = value(i.payments[0].assetId) | |
64 | 64 | if (!(isNft(token0))) | |
65 | 65 | then throw("Token is not NFT") | |
66 | 66 | else [StringEntry((toBase58String(assetid) + "_owner"), toString(i.caller)), IntegerEntry((toBase58String(assetid) + "_nft_selling_price"), price), StringEntry((toBase58String(assetid) + "_onsell"), "true"), IntegerEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
67 | 67 | } | |
68 | 68 | ||
69 | 69 |
github/deemru/w8io/169f3d6 59.89 ms ◑