tx · FFUyrG2x2EWNdTsmDSh5GN6A4JQukMuSmiJaHDcR6GBC 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves 2022.11.04 18:26 [2302544] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "FFUyrG2x2EWNdTsmDSh5GN6A4JQukMuSmiJaHDcR6GBC", "fee": 1000000, "feeAssetId": null, "timestamp": 1667575668545, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "3NT4ZQPNjruRK3wLD8Rpcpi7Cm5QPR5JQabJa8mv7ZFQxwkH3J3R6cZap8wmC1UovYeTuqxq9TTH7wUp4CGFjRMA" ], "script": "base64:BgIQCAISBQoDCAgBEgMKAQgSAAUACXNlcGFyYXRvcgIBXwAEa0J1eQIDYnV5AAVrU2VsbAIEc2VsbAAGa1ByaWNlAgVwcmljZQEFaXNOZnQBB2Fzc2V0SWQEByRtYXRjaDAJAOwHAQUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgVBc3NldAQFdG9rZW4FByRtYXRjaDADAwkAAAIIBQV0b2tlbghkZWNpbWFscwAACQAAAggFBXRva2VuCHF1YW50aXR5AAEHCQAAAggFBXRva2VuCnJlaXNzdWFibGUHBwcDAWkBCGlzc3VlTmZ0AwRuYW1lBG1ldGEFcHJpY2UECG5ld1Rva2VuCQDCCAUFBG5hbWUFBG1ldGEAAQAABwQHaXNzdWVJZAkAuAgBBQhuZXdUb2tlbgkAzAgCBQhuZXdUb2tlbgkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIIBQhuZXdUb2tlbghxdWFudGl0eQUHaXNzdWVJZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUGa1ByaWNlBQlzZXBhcmF0b3IJANgE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BORlQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyCQBoAgkBDXBhcnNlSW50VmFsdWUBBQVwcmljZQUHYW1vdW50MAUEdW5pdAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgkApQgBCAUBaQZjYWxsZXIFCXNlcGFyYXRvcgUFa1NlbGwJAKwCAgkArAICCQDYBAEFBnRva2VuMAUJc2VwYXJhdG9yCQCkAwEFB2Ftb3VudDAFA25pbADiRVmp", "height": 2302544, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: D76brpebbXP8T8kPFPHhFE1jCZMUPUnsWRc3kAR74LGH Next: EsECizHy6hm91G1y8r9YRUoiA523Hn6g1fkRQ4Besz1L Diff:
Old | New | Differences | |
---|---|---|---|
37 | 37 | let token0 = $t0805890._1 | |
38 | 38 | let amount0 = $t0805890._2 | |
39 | 39 | let price = valueOrErrorMessage(getStringValue(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
40 | - | if ((i.payments[0].assetId != unit)) | |
41 | - | then throw("Pay in waves") | |
42 | - | else if ((parseIntValue(price) > amount0)) | |
43 | - | then throw("Invalid payment attached") | |
44 | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))] | |
40 | + | [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))] | |
45 | 41 | } | |
46 | 42 | ||
47 | 43 | ||
48 | 44 | ||
49 | 45 | @Callable(i) | |
50 | 46 | func sellNFT () = { | |
51 | - | let $ | |
52 | - | let token0 = $ | |
53 | - | let amount0 = $ | |
47 | + | let $t011981283 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
48 | + | let token0 = $t011981283._1 | |
49 | + | let amount0 = $t011981283._2 | |
54 | 50 | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT"))) | |
55 | 51 | if (!(isNft(token0))) | |
56 | 52 | 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 (name,meta,price) = { | |
26 | 26 | let newToken = Issue(name, meta, 1, 0, false) | |
27 | 27 | let issueId = calculateAssetId(newToken) | |
28 | 28 | [newToken, ScriptTransfer(i.caller, newToken.quantity, issueId), StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | 33 | @Callable(i) | |
34 | 34 | func buyNFT (nftID) = { | |
35 | 35 | let assetId = fromBase58String(nftID) | |
36 | 36 | let $t0805890 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
37 | 37 | let token0 = $t0805890._1 | |
38 | 38 | let amount0 = $t0805890._2 | |
39 | 39 | let price = valueOrErrorMessage(getStringValue(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
40 | - | if ((i.payments[0].assetId != unit)) | |
41 | - | then throw("Pay in waves") | |
42 | - | else if ((parseIntValue(price) > amount0)) | |
43 | - | then throw("Invalid payment attached") | |
44 | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))] | |
40 | + | [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))] | |
45 | 41 | } | |
46 | 42 | ||
47 | 43 | ||
48 | 44 | ||
49 | 45 | @Callable(i) | |
50 | 46 | func sellNFT () = { | |
51 | - | let $ | |
52 | - | let token0 = $ | |
53 | - | let amount0 = $ | |
47 | + | let $t011981283 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
48 | + | let token0 = $t011981283._1 | |
49 | + | let amount0 = $t011981283._2 | |
54 | 50 | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT"))) | |
55 | 51 | if (!(isNft(token0))) | |
56 | 52 | then throw("Token is not NFT") | |
57 | 53 | else [ScriptTransfer(i.caller, (parseIntValue(price) * amount0), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
58 | 54 | } | |
59 | 55 | ||
60 | 56 |
github/deemru/w8io/026f985 25.42 ms ◑