tx · BCvKXonzm7qpH38oEoDcbJZ7HZt8LYzY5Gzso4HTLWKU 3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx: -0.01000000 Waves 2023.03.24 12:53 [2503931] smart account 3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx > SELF 0.00000000 Waves
{ "type": 13, "id": "BCvKXonzm7qpH38oEoDcbJZ7HZt8LYzY5Gzso4HTLWKU", "fee": 1000000, "feeAssetId": null, "timestamp": 1679651733133, "version": 2, "chainId": 84, "sender": "3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx", "senderPublicKey": "DyeDJ3fgwVVux2WRkxpLU9BbVjTM96AyV58b7bRFzCBx", "proofs": [ "4wvbLS1qzTtRPFKMRKGu5AZHCHjYWCGa8iyskqpmhe7p2LQaGCaJCZZTs1vmdGTprMaPc3dd2tBvGicXiPDVqZpi" ], "script": "base64:BgIJCAISBQoDGBgRAAEBaQEGYnV5TmZ0AwZzZWxsZXIEbmZ0cwVwcmljZQQFYnV5ZXIIBQFpBmNhbGxlcgQDbmZ0CQCQAwEFBG5mdHMEDGJ1eWVyQmFsYW5jZQkA8AcCBQVidXllcgEghWOVo/OIjrDeDBeOCE6/mj+SuybbOuh2jhbcFCIqSH4EBmFtb3VudAkBBXZhbHVlAQgJAJEDAggFAWkIcGF5bWVudHMAAAZhbW91bnQEBmxlbmd0aAkAsQIBAgVuZnRJZAoBA3N1bQIFYWNjdW0EbmV4dAkAZAIFBWFjY3VtBQRuZXh0BANhcnIFBXByaWNlBAl0b3RhbENvc3QKAAIkbAUDYXJyCgACJHMJAJADAQUCJGwKAAUkYWNjMAAACgEFJGYwXzECAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAQNzdW0CBQIkYQkAkQMCBQIkbAUCJGkKAQUkZjBfMgICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkAAgECE0xpc3Qgc2l6ZSBleGNlZWRzIDUJAQUkZjBfMgIJAQUkZjBfMQIJAQUkZjBfMQIJA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BQZ0d29Qcm8FA25pbAAzxI37", "height": 2503931, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J7KZs43MScEnSHLptzWoHV99BoyYVXHiwRsQFPm6JLZJ Next: 2DwtqPaLHE3bdr7sfArN4r2kt4fSLuGafQgpMuF4y1RD Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | @Callable(i) | |
7 | 7 | func buyNft (seller,nfts,price) = { | |
8 | 8 | let buyer = i.caller | |
9 | + | let nft = size(nfts) | |
9 | 10 | let buyerBalance = assetBalance(buyer, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq') | |
10 | 11 | let amount = value(i.payments[0].amount) | |
11 | 12 | let length = size("nftId") | |
12 | - | if (if ((size(nfts) != size(seller))) | |
13 | - | then true | |
14 | - | else (size(seller) != size(price))) | |
15 | - | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
16 | - | else if ((amount > buyerBalance)) | |
17 | - | then throw("Buyer does not have enough funds to complete the purchase.") | |
18 | - | else [StringEntry(toString(i.caller), toString(amount))] | |
13 | + | func sum (accum,next) = (accum + next) | |
14 | + | ||
15 | + | let arr = price | |
16 | + | let totalCost = { | |
17 | + | let $l = arr | |
18 | + | let $s = size($l) | |
19 | + | let $acc0 = 0 | |
20 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
21 | + | then $a | |
22 | + | else sum($a, $l[$i]) | |
23 | + | ||
24 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
25 | + | then $a | |
26 | + | else throw("List size exceeds 5") | |
27 | + | ||
28 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
29 | + | } | |
30 | + | func map (accum,next) = (accum :+ next) | |
31 | + | ||
32 | + | let brr = nfts | |
33 | + | let total = { | |
34 | + | let $l = brr | |
35 | + | let $s = size($l) | |
36 | + | let $acc0 = nil | |
37 | + | func $f1_1 ($a,$i) = if (($i >= $s)) | |
38 | + | then $a | |
39 | + | else map($a, $l[$i]) | |
40 | + | ||
41 | + | func $f1_2 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else throw("List size exceeds 5") | |
44 | + | ||
45 | + | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5) | |
46 | + | } | |
47 | + | let onePro = fromBase58String(total[0]) | |
48 | + | let twoPro = fromBase58String(total[1]) | |
49 | + | if ((amount != totalCost)) | |
50 | + | then throw("your paying ammount is wrong ") | |
51 | + | else if (if ((size(nfts) != size(seller))) | |
52 | + | then true | |
53 | + | else (size(seller) != size(price))) | |
54 | + | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
55 | + | else if ((amount > buyerBalance)) | |
56 | + | then throw("Buyer does not have enough funds to complete the purchase.") | |
57 | + | else [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, onePro), ScriptTransfer(buyer, 1, twoPro)] | |
19 | 58 | } | |
20 | 59 | ||
21 | 60 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func buyNft (seller,nfts,price) = { | |
8 | 8 | let buyer = i.caller | |
9 | + | let nft = size(nfts) | |
9 | 10 | let buyerBalance = assetBalance(buyer, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq') | |
10 | 11 | let amount = value(i.payments[0].amount) | |
11 | 12 | let length = size("nftId") | |
12 | - | if (if ((size(nfts) != size(seller))) | |
13 | - | then true | |
14 | - | else (size(seller) != size(price))) | |
15 | - | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
16 | - | else if ((amount > buyerBalance)) | |
17 | - | then throw("Buyer does not have enough funds to complete the purchase.") | |
18 | - | else [StringEntry(toString(i.caller), toString(amount))] | |
13 | + | func sum (accum,next) = (accum + next) | |
14 | + | ||
15 | + | let arr = price | |
16 | + | let totalCost = { | |
17 | + | let $l = arr | |
18 | + | let $s = size($l) | |
19 | + | let $acc0 = 0 | |
20 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
21 | + | then $a | |
22 | + | else sum($a, $l[$i]) | |
23 | + | ||
24 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
25 | + | then $a | |
26 | + | else throw("List size exceeds 5") | |
27 | + | ||
28 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
29 | + | } | |
30 | + | func map (accum,next) = (accum :+ next) | |
31 | + | ||
32 | + | let brr = nfts | |
33 | + | let total = { | |
34 | + | let $l = brr | |
35 | + | let $s = size($l) | |
36 | + | let $acc0 = nil | |
37 | + | func $f1_1 ($a,$i) = if (($i >= $s)) | |
38 | + | then $a | |
39 | + | else map($a, $l[$i]) | |
40 | + | ||
41 | + | func $f1_2 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else throw("List size exceeds 5") | |
44 | + | ||
45 | + | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5) | |
46 | + | } | |
47 | + | let onePro = fromBase58String(total[0]) | |
48 | + | let twoPro = fromBase58String(total[1]) | |
49 | + | if ((amount != totalCost)) | |
50 | + | then throw("your paying ammount is wrong ") | |
51 | + | else if (if ((size(nfts) != size(seller))) | |
52 | + | then true | |
53 | + | else (size(seller) != size(price))) | |
54 | + | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
55 | + | else if ((amount > buyerBalance)) | |
56 | + | then throw("Buyer does not have enough funds to complete the purchase.") | |
57 | + | else [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, onePro), ScriptTransfer(buyer, 1, twoPro)] | |
19 | 58 | } | |
20 | 59 | ||
21 | 60 |
github/deemru/w8io/169f3d6 38.92 ms ◑