tx · 62Tg79ihRh7qyTPbXNMaMcwXmkzAYCSzgywzf2cusKdj 3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx: -0.01000000 Waves 2023.03.27 18:48 [2508566] smart account 3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx > SELF 0.00000000 Waves
{ "type": 13, "id": "62Tg79ihRh7qyTPbXNMaMcwXmkzAYCSzgywzf2cusKdj", "fee": 1000000, "feeAssetId": null, "timestamp": 1679932323800, "version": 2, "chainId": 84, "sender": "3N5BTH4bjnXn7AAKoj4sswxytsPGmdXUuTx", "senderPublicKey": "DyeDJ3fgwVVux2WRkxpLU9BbVjTM96AyV58b7bRFzCBx", "proofs": [ "4zYbVh4NgPGJvA8AeKNUTruzm8eaM7iMEU8SfAojMsGeprDWi8GWJLKxVGHjxZbsQpBcWQd4hJNEseeP3cyNvRwL" ], "script": "base64:BgIICAISBAoCGAEBAAV0ZWFtcwEghWOVo/OIjrDeDBeOCE6/mj+SuybbOuh2jhbcFCIqSH4BAWkBDmJ1eUFsbFByb2R1Y3RzAgduZnRJbmZvC3RvdGFsYW1vdW50BAVidXllcggFAWkGY2FsbGVyBAxidXllckJhbGFuY2UJAPAHAgUFYnV5ZXIFBXRlYW1zBAZhbW91bnQJAQV2YWx1ZQEICQCRAwIIBQFpCHBheW1lbnRzAAAGYW1vdW50BARuZlQxCQC1CQIJAJEDAgUHbmZ0SW5mbwAAAgFfBARuZlQyCQC1CQIJAJEDAgUHbmZ0SW5mbwABAgFfBARuZlQzCQC1CQIJAJEDAgUHbmZ0SW5mbwACAgFfBARuZlQ0CQC1CQIJAJEDAgUHbmZ0SW5mbwADAgFfBARuZlQ1CQC1CQIJAJEDAgUHbmZ0SW5mbwAEAgFfAwkAZgIFC3RvdGFsYW1vdW50BQZhbW91bnQJAAIBAhx5b3VyIHBheWluZyBhbW91bnQgaXMgd3JvbmcgAwkAZgIFBmFtb3VudAUMYnV5ZXJCYWxhbmNlCQACAQI6QnV5ZXIgZG9lc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ACykotY", "height": 2508566, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 79JCZFSyNtVnuyy4wQ5EzuactLCnnwNYgdAEs5MXpnr6 Next: GDWBcjbXexDAiPSG8eWXFLhTtTULd8B229fgZyLBgbxe Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let teams = base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func | |
7 | + | func buyAllProducts (nftInfo,totalamount) = { | |
8 | 8 | let buyer = i.caller | |
9 | - | let nft = size(nfts) | |
10 | 9 | let buyerBalance = assetBalance(buyer, teams) | |
11 | 10 | let amount = value(i.payments[0].amount) | |
11 | + | let nfT1 = split(nftInfo[0], "_") | |
12 | + | let nfT2 = split(nftInfo[1], "_") | |
13 | + | let nfT3 = split(nftInfo[2], "_") | |
14 | + | let nfT4 = split(nftInfo[3], "_") | |
15 | + | let nfT5 = split(nftInfo[4], "_") | |
12 | 16 | if ((totalamount > amount)) | |
13 | - | then throw("your paying ammount is wrong ") | |
14 | - | else if (if ((size(nfts) != size(seller))) | |
15 | - | then true | |
16 | - | else (size(seller) != size(price))) | |
17 | - | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
18 | - | else if ((amount > buyerBalance)) | |
19 | - | then throw("Buyer does not have enough funds to complete the purchase.") | |
20 | - | else if (if (if ((size(nfts) == 1)) | |
21 | - | then true | |
22 | - | else (size(seller) == 1)) | |
23 | - | then true | |
24 | - | else (size(price) == 1)) | |
25 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams)] | |
26 | - | else if (if (if ((size(nfts) == 2)) | |
27 | - | then true | |
28 | - | else (size(seller) == 2)) | |
29 | - | then true | |
30 | - | else (size(price) == 2)) | |
31 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams)] | |
32 | - | else if (if (if ((size(nfts) == 3)) | |
33 | - | then true | |
34 | - | else (size(seller) == 3)) | |
35 | - | then true | |
36 | - | else (size(price) == 3)) | |
37 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams)] | |
38 | - | else if (if (if ((size(nfts) == 4)) | |
39 | - | then true | |
40 | - | else (size(seller) == 4)) | |
41 | - | then true | |
42 | - | else (size(price) == 4)) | |
43 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(buyer, 1, fromBase58String(nfts[3])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams), ScriptTransfer(Address(fromBase58String(seller[3])), price[3], teams)] | |
44 | - | else if (if (if ((size(nfts) == 5)) | |
45 | - | then true | |
46 | - | else (size(seller) == 5)) | |
47 | - | then true | |
48 | - | else (size(price) == 5)) | |
49 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(buyer, 1, fromBase58String(nfts[3])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams), ScriptTransfer(Address(fromBase58String(seller[3])), price[3], teams), ScriptTransfer(Address(fromBase58String(seller[4])), price[4], teams)] | |
17 | + | then throw("your paying amount is wrong ") | |
18 | + | else if ((amount > buyerBalance)) | |
19 | + | then throw("Buyer does not have enough funds to complete the purchase.") | |
20 | + | else if ((size(nftInfo) == 1)) | |
21 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams)] | |
22 | + | else if ((size(nftInfo) == 2)) | |
23 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams)] | |
24 | + | else if ((size(nftInfo) == 3)) | |
25 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams)] | |
26 | + | else if ((size(nftInfo) == 4)) | |
27 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams), ScriptTransfer(Address(fromBase58String(nfT4[1])), parseIntValue(nfT4[2]), teams)] | |
28 | + | else if ((size(nftInfo) == 5)) | |
29 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), StringEntry((((((("fifth_nft_Info=" + "nftId") + nfT5[0]) + "seller_address") + nfT5[1]) + "price") + nfT5[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT5[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams), ScriptTransfer(Address(fromBase58String(nfT4[1])), parseIntValue(nfT4[2]), teams), ScriptTransfer(Address(fromBase58String(nfT5[1])), parseIntValue(nfT5[2]), teams)] | |
30 | + | else if ((size(nftInfo) > 5)) | |
31 | + | then throw("sorry! maximum limit of your cart is 5 items") | |
50 | 32 | else nil | |
51 | 33 | } | |
52 | 34 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let teams = base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq' | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func | |
7 | + | func buyAllProducts (nftInfo,totalamount) = { | |
8 | 8 | let buyer = i.caller | |
9 | - | let nft = size(nfts) | |
10 | 9 | let buyerBalance = assetBalance(buyer, teams) | |
11 | 10 | let amount = value(i.payments[0].amount) | |
11 | + | let nfT1 = split(nftInfo[0], "_") | |
12 | + | let nfT2 = split(nftInfo[1], "_") | |
13 | + | let nfT3 = split(nftInfo[2], "_") | |
14 | + | let nfT4 = split(nftInfo[3], "_") | |
15 | + | let nfT5 = split(nftInfo[4], "_") | |
12 | 16 | if ((totalamount > amount)) | |
13 | - | then throw("your paying ammount is wrong ") | |
14 | - | else if (if ((size(nfts) != size(seller))) | |
15 | - | then true | |
16 | - | else (size(seller) != size(price))) | |
17 | - | then throw("Invalid input: Number of NFTs, seller addresses, and costs must be the same.") | |
18 | - | else if ((amount > buyerBalance)) | |
19 | - | then throw("Buyer does not have enough funds to complete the purchase.") | |
20 | - | else if (if (if ((size(nfts) == 1)) | |
21 | - | then true | |
22 | - | else (size(seller) == 1)) | |
23 | - | then true | |
24 | - | else (size(price) == 1)) | |
25 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams)] | |
26 | - | else if (if (if ((size(nfts) == 2)) | |
27 | - | then true | |
28 | - | else (size(seller) == 2)) | |
29 | - | then true | |
30 | - | else (size(price) == 2)) | |
31 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams)] | |
32 | - | else if (if (if ((size(nfts) == 3)) | |
33 | - | then true | |
34 | - | else (size(seller) == 3)) | |
35 | - | then true | |
36 | - | else (size(price) == 3)) | |
37 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams)] | |
38 | - | else if (if (if ((size(nfts) == 4)) | |
39 | - | then true | |
40 | - | else (size(seller) == 4)) | |
41 | - | then true | |
42 | - | else (size(price) == 4)) | |
43 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(buyer, 1, fromBase58String(nfts[3])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams), ScriptTransfer(Address(fromBase58String(seller[3])), price[3], teams)] | |
44 | - | else if (if (if ((size(nfts) == 5)) | |
45 | - | then true | |
46 | - | else (size(seller) == 5)) | |
47 | - | then true | |
48 | - | else (size(price) == 5)) | |
49 | - | then [StringEntry(toString(i.caller), toString(amount)), ScriptTransfer(buyer, 1, fromBase58String(nfts[0])), ScriptTransfer(buyer, 1, fromBase58String(nfts[1])), ScriptTransfer(buyer, 1, fromBase58String(nfts[2])), ScriptTransfer(buyer, 1, fromBase58String(nfts[3])), ScriptTransfer(Address(fromBase58String(seller[0])), price[0], teams), ScriptTransfer(Address(fromBase58String(seller[1])), price[1], teams), ScriptTransfer(Address(fromBase58String(seller[2])), price[2], teams), ScriptTransfer(Address(fromBase58String(seller[3])), price[3], teams), ScriptTransfer(Address(fromBase58String(seller[4])), price[4], teams)] | |
17 | + | then throw("your paying amount is wrong ") | |
18 | + | else if ((amount > buyerBalance)) | |
19 | + | then throw("Buyer does not have enough funds to complete the purchase.") | |
20 | + | else if ((size(nftInfo) == 1)) | |
21 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams)] | |
22 | + | else if ((size(nftInfo) == 2)) | |
23 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams)] | |
24 | + | else if ((size(nftInfo) == 3)) | |
25 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams)] | |
26 | + | else if ((size(nftInfo) == 4)) | |
27 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams), ScriptTransfer(Address(fromBase58String(nfT4[1])), parseIntValue(nfT4[2]), teams)] | |
28 | + | else if ((size(nftInfo) == 5)) | |
29 | + | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), StringEntry((((((("fifth_nft_Info=" + "nftId") + nfT5[0]) + "seller_address") + nfT5[1]) + "price") + nfT5[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT5[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), parseIntValue(nfT1[2]), teams), ScriptTransfer(Address(fromBase58String(nfT2[1])), parseIntValue(nfT2[2]), teams), ScriptTransfer(Address(fromBase58String(nfT3[1])), parseIntValue(nfT3[2]), teams), ScriptTransfer(Address(fromBase58String(nfT4[1])), parseIntValue(nfT4[2]), teams), ScriptTransfer(Address(fromBase58String(nfT5[1])), parseIntValue(nfT5[2]), teams)] | |
30 | + | else if ((size(nftInfo) > 5)) | |
31 | + | then throw("sorry! maximum limit of your cart is 5 items") | |
50 | 32 | else nil | |
51 | 33 | } | |
52 | 34 | ||
53 | 35 |
github/deemru/w8io/169f3d6 31.55 ms ◑