tx · DsMjkGrzCzAT6gPs1qEqLYfAQJccqP8TeLQQkR9eXAPv

3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H:  -0.01000000 Waves

2022.11.04 15:25 [2302368] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves

{ "type": 13, "id": "DsMjkGrzCzAT6gPs1qEqLYfAQJccqP8TeLQQkR9eXAPv", "fee": 1000000, "feeAssetId": null, "timestamp": 1667564781055, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "3EoJwy7WTBht4wZ3rxmZPi5DvPpTcPUdV3TtFLDKBVVCrQnDXyymzceB44S8AWNhFsPbADjpW5Kii3uMFqexL4mY" ], "script": "base64:BgIRCAISABIFCgMCCAgSBAoCAggVAAlzZXBhcmF0b3ICAV8AC2tDb2xsZWN0aW9uAgpjb2xsZWN0aW9uAARrTmZ0AgNuZnQAEUNPTExFQ1RJT05TX0xJTUlUAPQDAAlORlRfTElNSVQA9AMBEGdldENvbGxlY3Rpb25LZXkBDGNvbGxlY3Rpb25JZAkAuQkCCQDMCAIFC2tDb2xsZWN0aW9uCQDMCAIJANgEAQUMY29sbGVjdGlvbklkBQNuaWwFCXNlcGFyYXRvcgESZ2V0Q29sbGVjdGlvblZhbHVlAgtjb2xsZWN0aW9ucwxjb2xsZWN0aW9uSWQJALkJAgkAzAgCBQtjb2xsZWN0aW9ucwkAzAgCCQDYBAEFDGNvbGxlY3Rpb25JZAUDbmlsBQlzZXBhcmF0b3IBCWdldE5mdEtleQEFbmZ0SWQJALkJAgkAzAgCBQRrTmZ0CQDMCAIJANgEAQUFbmZ0SWQFA25pbAUJc2VwYXJhdG9yAQtnZXROZnRWYWx1ZQIEbmZ0cwVuZnRJZAkAuQkCCQDMCAIFBG5mdHMJAMwIAgkA2AQBBQVuZnRJZAUD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9uSWQFA25pbAFpAQRtaW50Awxjb2xsZWN0aW9uSWQEbmFtZQRtZXRhAwkBASEBCQERaXNDb2xsZWN0aW9uRXhpc3QCCAUBaQZjYWxsZXIFDGNvbGxlY3Rpb25JZAkAAgECHVdyb25nIGNvbGxlY3Rpb24gb3IgY2FsbGVyIElEAwkBEmlzTmZ0c0xpbWl0UmVhY2hlZAEFDGNvbGxlY3Rpb25JZAkAAgECKVlvdSByZWFjaGVkIG5mdHMgbGltaXQgaW4gdGhpcyBjb2xsZWN0aW9uBAhuZXdUb2tlbgkAwggFBQRuYW1lBQRtZXRhAAEAAAcEB2lzc3VlSWQJALgIAQUIbmV3VG9rZW4JAMwIAgUIbmV3VG9rZW4JAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyCAUIbmV3VG9rZW4IcXVhbnRpdHkFB2lzc3VlSWQJAMwIAgkBFXNldE5mdHNGcm9tQ29sbGVjdGlvbgMFDGNvbGxlY3Rpb25JZAkBHmdldE5mdHNGcm9tQ29sbGVjdGlvbkZvclVwZGF0ZQEFDGNvbGxlY3Rpb25JZAUHaXNzdWVJZAUDbmlsAWkBCnNldENvbnRlbnQCBW5mdElkB2NvbnRlbnQJAQt2YWx1ZU9yRWxzZQIJAQ9pc0NvcnJlY3RDYWxsZXICBQVuZnRJZAgFAWkGY2FsbGVyCQDMCAIJAQtTdHJpbmdFbnRyeQIJAQlnZXROZnRLZXkBBQVuZnRJZAUHY29udGVudAUDbmlsAPRmB6c=", "height": 2302368, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: JCppjZfE3119Zr8BcwDsr3p4uiAT2bjtfBgqdZd4cJdK Next: DsLcwqCtckvqSCfr4BeG9ntsTXWq4ZvTQDSTT18qcXJ5 Full:
OldNewDifferences
1-{-# STDLIB_VERSION 3 #-}
1+{-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let maxAuctionDuration = (1440 * 30)
4+let separator = "_"
5+
6+let kCollection = "collection"
7+
8+let kNft = "nft"
9+
10+let COLLECTIONS_LIMIT = 500
11+
12+let NFT_LIMIT = 500
13+
14+func getCollectionKey (collectionId) = makeString([kCollection, toBase58String(collectionId)], separator)
15+
16+
17+func getCollectionValue (collections,collectionId) = makeString([collections, toBase58String(collectionId)], separator)
18+
19+
20+func getNftKey (nftId) = makeString([kNft, toBase58String(nftId)], separator)
21+
22+
23+func getNftValue (nfts,nftId) = makeString([nfts, toBase58String(nftId)], separator)
24+
25+
26+func getOwnerCollections (owner) = split(valueOrElse(getString(this, toString(owner)), ""), separator)
27+
28+
29+func getNftsFromCollection (collectionId) = split(valueOrElse(getString(this, getCollectionKey(collectionId)), ""), separator)
30+
31+
32+func getOwnerCollectionsForUpdate (owner) = valueOrElse(getString(this, toString(owner)), "")
33+
34+
35+func getNftsFromCollectionForUpdate (collectionId) = valueOrElse(getString(this, getCollectionKey(collectionId)), "")
36+
37+
38+func setOwnerCollection (owner,collections,collectionId) = if ((collections == ""))
39+ then StringEntry(toString(owner), toBase58String(collectionId))
40+ else StringEntry(toString(owner), getCollectionValue(collections, collectionId))
41+
42+
43+func setNftsFromCollection (collectionId,nfts,nftId) = if ((nfts == ""))
44+ then StringEntry(getCollectionKey(collectionId), toBase58String(nftId))
45+ else StringEntry(getCollectionKey(collectionId), getNftValue(nfts, nftId))
46+
47+
48+func isCollectionsLimitReached (caller) = (size(getOwnerCollections(caller)) > COLLECTIONS_LIMIT)
49+
50+
51+func isNftsLimitReached (collectionId) = (size(getNftsFromCollection(collectionId)) > NFT_LIMIT)
52+
53+
54+func isOwner (nftId,caller) = (assetBalance(caller, nftId) == 1)
55+
56+
57+func isAlreadySetted (nftId) = isDefined(getString(this, getNftKey(nftId)))
58+
59+
60+func isCollectionExist (owner,collectionId) = {
61+ let collectionsArray = getOwnerCollections(owner)
62+ containsElement(collectionsArray, toBase58String(collectionId))
63+ }
64+
65+
66+func isCorrectCaller (nftId,caller) = if (!(isOwner(nftId, caller)))
67+ then throw("Caller is not owner of nft")
68+ else if (isAlreadySetted(nftId))
69+ then throw("Content already setted for this nft")
70+ else unit
71+
572
673 @Callable(i)
7-func startAuction (duration,startPrice,priceAssetId) = {
8- let auctionId = toBase58String(i.transactionId)
9- let endHeight = (lastBlock.height + duration)
10- let pmt = extract(i.payment)
11- if ((duration > maxAuctionDuration))
12- then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration)))
13- else WriteSet([DataEntry(auctionId, endHeight), DataEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId))
14- then toBase58String(value(pmt.assetId))
15- else "WAVES"), DataEntry((auctionId + "_lot_amount"), pmt.amount), DataEntry((auctionId + "_startPrice"), startPrice), DataEntry((auctionId + "_priceAssetId"), priceAssetId)])
16- }
74+func addCollection () = if (isCollectionsLimitReached(i.caller))
75+ then throw("You reached collections limit")
76+ else [setOwnerCollection(i.caller, getOwnerCollectionsForUpdate(i.caller), i.transactionId)]
1777
1878
1979
2080 @Callable(i)
21-func bid (auctionId) = {
22- let pmt = extract(i.payment)
23- let pmtAssetIdStr = if (isDefined(pmt.assetId))
24- then toBase58String(value(pmt.assetId))
25- else "WAVES"
26- let callerAddressStr = toBase58String(i.caller.bytes)
27- let endHeight = getIntegerValue(this, auctionId)
28- let startPrice = getIntegerValue(this, (auctionId + "_startPrice"))
29- let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId"))
30- let winAmount = getInteger(this, (auctionId + "_winAmount"))
31- let winner = getString(this, (auctionId + "_winner"))
32- let bidFromTheSameUser = if (isDefined(winner))
33- then (value(winner) == callerAddressStr)
34- else false
35- let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser)
36- then value(winAmount)
37- else 0))
38- if ((lastBlock.height >= endHeight))
39- then throw("Auction already finished")
40- else if ((priceAssetId != pmtAssetIdStr))
41- then throw((("Bid must be in asset '" + priceAssetId) + "'"))
42- else if (if (if (isDefined(winAmount))
43- then (value(winAmount) >= totalBidAmount)
44- else false)
45- then true
46- else if (!(isDefined(winAmount)))
47- then (startPrice >= totalBidAmount)
48- else false)
49- then throw(("Bid must be more then " + toString(if (isDefined(winAmount))
50- then value(winAmount)
51- else startPrice)))
52- else if (if (bidFromTheSameUser)
53- then true
54- else !(isDefined(winner)))
55- then WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)])
56- else {
57- let previousBidderAddr = addressFromStringValue(value(winner))
58- let priceAsset = if (if ((priceAssetId == "WAVES"))
59- then true
60- else (priceAssetId == ""))
61- then unit
62- else fromBase58String(priceAssetId)
63- ScriptResult(WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)]))
64- }
65- }
81+func mint (collectionId,name,meta) = if (!(isCollectionExist(i.caller, collectionId)))
82+ then throw("Wrong collection or caller ID")
83+ else if (isNftsLimitReached(collectionId))
84+ then throw("You reached nfts limit in this collection")
85+ else {
86+ let newToken = Issue(name, meta, 1, 0, false)
87+ let issueId = calculateAssetId(newToken)
88+[newToken, ScriptTransfer(i.caller, newToken.quantity, issueId), setNftsFromCollection(collectionId, getNftsFromCollectionForUpdate(collectionId), issueId)]
89+ }
6690
6791
6892
6993 @Callable(i)
70-func withdraw (auctionId) = {
71- let pmt = extract(i.payment)
72- let pmtAssetIdStr = if (isDefined(pmt.assetId))
73- then toBase58String(value(pmt.assetId))
74- else "WAVES"
75- let callerAddressStr = toBase58String(i.caller.bytes)
76- let endHeight = getIntegerValue(this, auctionId)
77- let organizer = getStringValue(this, (auctionId + "_organizer"))
78- let winner = getString(this, (auctionId + "_winner"))
79- let lotAssetId = getStringValue(this, (auctionId + "_lot_assetId"))
80- let lotAmount = getIntegerValue(this, (auctionId + "_lot_amount"))
81- let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId"))
82- let winAmount = getIntegerValue(this, (auctionId + "_winAmount"))
83- let lotAsset = if ((lotAssetId == "WAVES"))
84- then unit
85- else fromBase58String(lotAssetId)
86- let priceAsset = if (if ((priceAssetId == "WAVES"))
87- then true
88- else (priceAssetId == ""))
89- then unit
90- else fromBase58String(priceAssetId)
91- let winnerAddr = addressFromStringValue(value(winner))
92- let organizerAddr = addressFromStringValue(value(organizer))
93- let betAmount = getInteger(this, ((auctionId + "_bidder_") + callerAddressStr))
94- if ((endHeight > lastBlock.height))
95- then throw("Auction is not finished yet")
96- else if (!(isDefined(winner)))
97- then if (isDefined(getString(this, (auctionId + "_lot_passed"))))
98- then throw("Organizer has already got his lot back")
99- else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), organizer)]), TransferSet([ScriptTransfer(organizerAddr, lotAmount, lotAsset)]))
100- else if (isDefined(getString(this, (auctionId + "_lot_passed"))))
101- then throw("Lot is already passed to the winner, and organizer got his reward")
102- else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes))]), TransferSet([ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)]))
103- }
94+func setContent (nftId,content) = valueOrElse(isCorrectCaller(nftId, i.caller), [StringEntry(getNftKey(nftId), content)])
10495
10596

github/deemru/w8io/026f985 
28.53 ms