tx · GR7p6Vduaz5APMBSZ5h6LZvqgTSsTw4RkDrFKssHJpgm 3My7JvybytBTv6LBND2MeZCbkeUS7jR3PiK: -0.01000000 Waves 2022.11.09 08:19 [2309165] smart account 3My7JvybytBTv6LBND2MeZCbkeUS7jR3PiK > SELF 0.00000000 Waves
{ "type": 13, "id": "GR7p6Vduaz5APMBSZ5h6LZvqgTSsTw4RkDrFKssHJpgm", "fee": 1000000, "feeAssetId": null, "timestamp": 1667971261505, "version": 2, "chainId": 84, "sender": "3My7JvybytBTv6LBND2MeZCbkeUS7jR3PiK", "senderPublicKey": "FVTpXbDNs3kNEiYy4vjvjfzxbQim8PuN6fNLFntwM31j", "proofs": [ "3qN9aBKg8SR9JiKtrUyBcRUKST1AYvV68S1dMdyFumo87XPi9iWtyLgbaq8HcYMWGy7xtoXnoQgf3zjc7N4tFcAB" ], "script": "base64:AAIFAAAAAAAAABAIAhIFCgMICAESAwoBCBIAAAAABQAAAAAJc2VwYXJhdG9yAgAAAAFfAAAAAARrQnV5AgAAAANidXkAAAAABWtTZWxsAgAAAARzZWxsAAAAAAZrUHJpY2UCAAAABXByaWNlAQAAAAVpc05mdAAAAAEAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAkAA+wAAAABBQAAAAdhc3NldElkAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAVBc3NldAQAAAAFdG9rZW4FAAAAByRtYXRjaDADAwkAAAAAAAACCAUAAAAFdG9rZW4AAAAIZGVjaW1hbHMAAAAAAAAAAAAJAAAAAAAAAggFAAAABXRva2VuAAAACHF1YW50aXR5AAAAAAAAAAABBwkAAAAAAAACCAUAAAAFdG9rZW4AAAAKcmVpc3N1YWJsZQcHBwAAAAMAAAABaQEAAAAIaXNzdWVOZnQAAAADAAAABG5hbWUAAAAEbWV0YQAAAAVwcmljZQQAAAAIbmV3VG9rZW4JAARCAAAABQUAAAAEbmFtZQUAAAAEbWV0YQAAAAAAAAAAAQAAAAAAAAAAAAcEAAAAB2lzc3Vl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ABmFtb3VudAUAAAADbmlsAAAAAWkBAAAAB3NlbGxORlQAAAAABAAAAAskdDAxMTczMTI1OAkABRQAAAACCQEAAAAFdmFsdWUAAAABCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAdhc3NldElkCQEAAAAFdmFsdWUAAAABCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQEAAAABnRva2VuMAgFAAAACyR0MDExNzMxMjU4AAAAAl8xBAAAAAdhbW91bnQwCAUAAAALJHQwMTE3MzEyNTgAAAACXzIEAAAABXByaWNlCQEAAAARQGV4dHJOYXRpdmUoMTA1OCkAAAABCQABLAAAAAIJAAEsAAAAAgUAAAAGa1ByaWNlBQAAAAlzZXBhcmF0b3IJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkAAlgAAAABBQAAAAZ0b2tlbjACAAAAHlRoZXJlIGlzIG5vIHByaWNlIGZvciB0aGlzIG5mdAMJAQAAAAEhAAAAAQkBAAAABWlzTmZ0AAAAAQUAAAAGdG9rZW4wCQAAAgAAAAECAAAAEFRva2VuIGlzIG5vdCBORlQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyCQEAAAANcGFyc2VJbnRWYWx1ZQAAAAEFAAAABXByaWNlBQAAAAR1bml0CQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQAEJQAAAAEIBQAAAAFpAAAABmNhbGxlcgUAAAAJc2VwYXJhdG9yBQAAAAVrU2VsbAkAASwAAAACCQABLAAAAAIJAAJYAAAAAQUAAAAGdG9rZW4wBQAAAAlzZXBhcmF0b3IJAAGkAAAAAQUAAAAHYW1vdW50MAUAAAADbmlsAAAAAMC2gcI=", "height": 2309165, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 6x4aY6ZaNaZzGgKHPUr7VAyyDKQEBckyroE3JGAE3Hp2 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let separator = "_" | |
5 | + | ||
6 | + | let kBuy = "buy" | |
7 | + | ||
8 | + | let kSell = "sell" | |
9 | + | ||
10 | + | let kPrice = "price" | |
11 | + | ||
12 | + | func isNft (assetId) = match assetInfo(assetId) { | |
13 | + | case token: Asset => | |
14 | + | if (if ((token.decimals == 0)) | |
15 | + | then (token.quantity == 1) | |
16 | + | else false) | |
17 | + | then (token.reissuable == false) | |
18 | + | else false | |
19 | + | case _ => | |
20 | + | false | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | @Callable(i) | |
25 | + | func issueNft (name,meta,price) = { | |
26 | + | let newToken = Issue(name, meta, 1, 0, false) | |
27 | + | let issueId = calculateAssetId(newToken) | |
28 | + | [newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] | |
29 | + | } | |
30 | + | ||
31 | + | ||
32 | + | ||
33 | + | @Callable(i) | |
34 | + | func buyNFT (nftID) = { | |
35 | + | let assetId = fromBase58String(nftID) | |
36 | + | let amount = value(i.payments[0].amount) | |
37 | + | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this nft") | |
38 | + | if ((i.payments[0].assetId != unit)) | |
39 | + | then throw("pay in waves") | |
40 | + | else if ((parseIntValue(price) > amount)) | |
41 | + | then throw("Invalid payment") | |
42 | + | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | ||
47 | + | @Callable(i) | |
48 | + | func sellNFT () = { | |
49 | + | let $t011731258 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
50 | + | let token0 = $t011731258._1 | |
51 | + | let amount0 = $t011731258._2 | |
52 | + | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this nft"))) | |
53 | + | if (!(isNft(token0))) | |
54 | + | then throw("Token is not NFT") | |
55 | + | else [ScriptTransfer(i.caller, parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
56 | + | } | |
57 | + | ||
58 | + |
github/deemru/w8io/026f985 31.82 ms ◑