tx · 6jJwfeyjCmZ7SMERF9vngfQiWN5pZmMhQo9wdj87Ma1j
3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves
2022.11.11 09:59 [2312155] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{
"type": 13,
"id": "6jJwfeyjCmZ7SMERF9vngfQiWN5pZmMhQo9wdj87Ma1j",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1668149946033,
"version": 2,
"chainId": 84,
"sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H",
"senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu",
"proofs": [
"5H3exnrQyHXzmGnY9eAWdo2wNzfpXhkgyhZk24yQ3B6Axy3nXuWQvRS8Pgz5r3ovTB6XbXjNgodXB9XpezV4SCPb"
],
"script": "base64:BgISCAISBAoCCAgSAwoBCBIDCgEBBQAJc2VwYXJhdG9yAgFfAARrQnV5AgNidXkABWtTZWxsAgRzZWxsAAZrUHJpY2UCBXByaWNlAQVpc05mdAEHYXNzZXRJZAQHJG1hdGNoMAkA7AcBBQdhc3NldElkAwkAAQIFByRtYXRjaDACBUFzc2V0BAV0b2tlbgUHJG1hdGNoMAMDCQAAAggFBXRva2VuCGRlY2ltYWxzAAAJAAACCAUFdG9rZW4IcXVhbnRpdHkAAQcJAAACCAUFdG9rZW4KcmVpc3N1YWJsZQcHBwMBaQEIaXNzdWVOZnQCBG5hbWUEbWV0YQQIbmV3VG9rZW4JAMIIBQUEbmFtZQUEbWV0YQABAAAHBAdpc3N1ZUlkCQC4CAEFCG5ld1Rva2VuCQDMCAIFCG5ld1Rva2VuCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgABBQdpc3N1ZUlkCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICCQDYBAEFB2lzc3VlSWQFCXNlcGFyYXRvcgIFT3duZXIJA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R0MDEzOTgxNDgzAl8yAwkBASEBCQEFaXNOZnQBBQZ0b2tlbjAJAAIBAhBUb2tlbiBpcyBub3QgTkZUCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICBQZrUHJpY2UFCXNlcGFyYXRvcgkA2AQBCQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAAB2Fzc2V0SWQJAKQDAQUFcHJpY2UJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyAAEJAQV2YWx1ZQEICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgkApQgBCAUBaQZjYWxsZXIFCXNlcGFyYXRvcgUFa1NlbGwJAKwCAgkArAICCQDYBAEFBnRva2VuMAUJc2VwYXJhdG9yCQCkAwEFB2Ftb3VudDAFA25pbAAxfJi2",
"height": 2312155,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: JBHvKDnQMeu2kpZQV5Ypg6Pkvx4RgtGeRUCYLsb8ysky
Next: EcxZeLzmt4g7gXgLDKVKYjy5N3iiZzKPWZtH1RUkYV8r
Diff:
Old | New | | Differences |
---|
22 | 22 | | |
---|
23 | 23 | | |
---|
24 | 24 | | @Callable(i) |
---|
25 | | - | func issueNft (name,meta,price) = { |
---|
| 25 | + | func issueNft (name,meta) = { |
---|
26 | 26 | | let newToken = Issue(name, meta, 1, 0, false) |
---|
27 | 27 | | let issueId = calculateAssetId(newToken) |
---|
28 | | - | [newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] |
---|
| 28 | + | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] |
---|
29 | 29 | | } |
---|
30 | 30 | | |
---|
31 | 31 | | |
---|
|
35 | 35 | | let assetId = fromBase58String(nftID) |
---|
36 | 36 | | let amount = value(i.payments[0].amount) |
---|
37 | 37 | | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") |
---|
| 38 | + | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") |
---|
38 | 39 | | if ((i.payments[0].assetId != unit)) |
---|
39 | 40 | | then throw("Pay in waves") |
---|
40 | 41 | | else if ((parseIntValue(price) > amount)) |
---|
41 | 42 | | then throw("Invalid payment") |
---|
42 | | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] |
---|
| 43 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] |
---|
43 | 44 | | } |
---|
44 | 45 | | |
---|
45 | 46 | | |
---|
46 | 47 | | |
---|
47 | 48 | | @Callable(i) |
---|
48 | | - | func sellNFT () = { |
---|
49 | | - | let $t011791264 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
50 | | - | let token0 = $t011791264._1 |
---|
51 | | - | let amount0 = $t011791264._2 |
---|
52 | | - | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT"))) |
---|
| 49 | + | func sellNFT (price) = { |
---|
| 50 | + | let $t013981483 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
| 51 | + | let token0 = $t013981483._1 |
---|
| 52 | + | let amount0 = $t013981483._2 |
---|
53 | 53 | | if (!(isNft(token0))) |
---|
54 | 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)))] |
---|
| 55 | + | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), ScriptTransfer(i.caller, 1, value(i.payments[0].assetId)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] |
---|
56 | 56 | | } |
---|
57 | 57 | | |
---|
58 | 58 | | |
---|
Full:
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 | | - | func issueNft (name,meta,price) = { |
---|
| 25 | + | func issueNft (name,meta) = { |
---|
26 | 26 | | let newToken = Issue(name, meta, 1, 0, false) |
---|
27 | 27 | | let issueId = calculateAssetId(newToken) |
---|
28 | | - | [newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] |
---|
| 28 | + | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] |
---|
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 amount = value(i.payments[0].amount) |
---|
37 | 37 | | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") |
---|
| 38 | + | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") |
---|
38 | 39 | | if ((i.payments[0].assetId != unit)) |
---|
39 | 40 | | then throw("Pay in waves") |
---|
40 | 41 | | else if ((parseIntValue(price) > amount)) |
---|
41 | 42 | | then throw("Invalid payment") |
---|
42 | | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] |
---|
| 43 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] |
---|
43 | 44 | | } |
---|
44 | 45 | | |
---|
45 | 46 | | |
---|
46 | 47 | | |
---|
47 | 48 | | @Callable(i) |
---|
48 | | - | func sellNFT () = { |
---|
49 | | - | let $t011791264 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
50 | | - | let token0 = $t011791264._1 |
---|
51 | | - | let amount0 = $t011791264._2 |
---|
52 | | - | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT"))) |
---|
| 49 | + | func sellNFT (price) = { |
---|
| 50 | + | let $t013981483 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
| 51 | + | let token0 = $t013981483._1 |
---|
| 52 | + | let amount0 = $t013981483._2 |
---|
53 | 53 | | if (!(isNft(token0))) |
---|
54 | 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)))] |
---|
| 55 | + | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), ScriptTransfer(i.caller, 1, value(i.payments[0].assetId)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] |
---|
56 | 56 | | } |
---|
57 | 57 | | |
---|
58 | 58 | | |
---|