MarketplaceSEALED
#??╱□╲%■▪○%~█▪▫@!╱&╳&□░%▓░◆█@○^○█▫^^╱!@●╲?□~□█!%$░#□*~◇○$^#▒$!▫╱
Transaction ID
Transaction Summary
MarketplaceCalled DapperUtilityCoin, FungibleToken, NonFungibleToken +4 more
Script Arguments
0collectionIdentifierString
LaligaGolazos
1saleItemIDUInt64
987729102
2saleItemPriceUFix64
0.10000000
3customIDString?
null
4buyerAddress?
null
5expiryUInt64
2592000
Cadence Script
1import DapperUtilityCoin from 0xead892083b3e2c6c
2import FungibleToken from 0xf233dcee88fe0abe
3import NonFungibleToken from 0x1d7e57aa55817448
4import MetadataViews from 0x1d7e57aa55817448
5import NFTCatalog from 0x49a7cda3a1eecc29
6import NFTStorefrontV2 from 0x3cdbb3d569211ff3
7import TokenForwarding from 0xe544175ee0461c4b
8
9/// Transaction used to facilitate the creation of the listing under the signer's owned storefront resource.
10/// It accepts the certain details from the signer,i.e. -
11///
12/// `saleItemID` - ID of the NFT that is put on sale by the seller.
13/// `saleItemPrice` - Amount of tokens (FT) buyer needs to pay for the purchase of listed NFT.
14/// `customID` - Optional string to represent identifier of the dapp.
15/// `buyer` - Optional address for the only address that is permitted to fill this listing
16/// `expiry` - Unix timestamp at which created listing become expired.
17
18/// If the given nft has a support of the RoyaltyView then royalties will added as the sale cut.
19
20transaction(collectionIdentifier: String, saleItemID: UInt64, saleItemPrice: UFix64, customID: String?, buyer: Address?, expiry: UInt64) {
21 let paymentReceiver: Capability<&AnyResource{FungibleToken.Receiver}>
22 let collectionCap: Capability<&AnyResource{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
23 let storefront: &NFTStorefrontV2.Storefront
24 let nftType: Type
25
26 prepare(seller: AuthAccount) {
27 if seller.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil {
28 // Create a new empty Storefront
29 let storefront <- NFTStorefrontV2.createStorefront() as! @NFTStorefrontV2.Storefront
30 // save it to the account
31 seller.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath)
32 // create a public capability for the Storefront, first unlinking to ensure we remove anything that's already present
33 seller.unlink(NFTStorefrontV2.StorefrontPublicPath)
34 seller.link<&NFTStorefrontV2.Storefront{NFTStorefrontV2.StorefrontPublic}>(NFTStorefrontV2.StorefrontPublicPath, target: NFTStorefrontV2.StorefrontStoragePath)
35 }
36
37 let value = NFTCatalog.getCatalogEntry(collectionIdentifier: collectionIdentifier) ?? panic("Provided collection is not in the NFT Catalog.")
38
39 // We need a provider capability, but one is not provided by default so we create one if needed.
40 let nftCollectionProviderPrivatePath = PrivatePath(identifier: collectionIdentifier.concat("CollectionProviderForFlowtyNFTStorefront"))!
41
42 // Receiver for the sale cut.
43 self.paymentReceiver = seller.getCapability<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
44 assert(self.paymentReceiver.borrow() != nil, message: "Missing or mis-typed DapperUtilityCoin receiver")
45
46 self.collectionCap = seller.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(nftCollectionProviderPrivatePath)
47 if !self.collectionCap.check() {
48 seller.unlink(nftCollectionProviderPrivatePath)
49 seller.link<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(nftCollectionProviderPrivatePath, target: value.collectionData.storagePath)
50 }
51
52 let collection = self.collectionCap.borrow()
53 ?? panic("Could not borrow a reference to the collection")
54 assert(self.collectionCap.borrow() != nil, message: "Missing or mis-typed NonFungibleToken.Provider, NonFungibleToken.CollectionPublic provider")
55 let nft = collection.borrowNFT(id: saleItemID)
56 self.nftType = nft.getType()
57
58 self.storefront = seller.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath)
59 ?? panic("Missing or mis-typed NFTStorefront Storefront")
60 }
61
62 execute {
63 // check for existing listings of the NFT
64 var existingListingIDs = self.storefront.getExistingListingIDs(
65 nftType: self.nftType,
66 nftID: saleItemID
67 )
68 // remove existing listings
69 for listingID in existingListingIDs {
70 self.storefront.removeListing(listingResourceID: listingID)
71 }
72
73 // Create listing
74 self.storefront.createListing(
75 nftProviderCapability: self.collectionCap,
76 paymentReceiver: self.paymentReceiver,
77 nftType: self.nftType,
78 nftID: saleItemID,
79 salePaymentVaultType: Type<@DapperUtilityCoin.Vault>(),
80 price: saleItemPrice,
81 customID: customID,
82 expiry: UInt64(getCurrentBlock().timestamp) + expiry,
83 buyer: buyer
84 )
85 }
86}