MarketplaceSEALED

~~!&□■╱□□▫!▫^^%╳╲●╱██░▒■$^╱!●□░?$◇▒■░$^@▪░%╲▪█@▫╲╲*■%▓╳▒■~*●!●◇○

Transaction ID

Timestamp

Aug 08, 2025, 04:28:07 PM UTC
6mo ago

Block Height

122,288,378

Computation

0

Execution Fee

0.00003573 FLOW

Transaction Summary

Marketplace

Called FlowToken, FungibleToken, NonFungibleToken +7 more

Script Arguments

0saleItemIDUInt64
2006300
1saleItemPriceUFix64
2.249995
2customIDString?
RARIBLE
3commissionAmountUFix64
0.0
4expiryUInt64
1770571681
5marketplacesAddress[Address]

Cadence Script

1import FlowToken from 0x1654653399040a61
2import FungibleToken from 0xf233dcee88fe0abe
3import NonFungibleToken from 0x1d7e57aa55817448
4import MetadataViews from 0x1d7e57aa55817448
5import NFTStorefrontV2 from 0x4eb8a10cb9f87357
6
7    import HWGarageCard from 0xd0bcefdf1e67ea85
8    import HWGaragePack from 0xd0bcefdf1e67ea85
9    import HWGarageCardV2 from 0xd0bcefdf1e67ea85
10    import HWGaragePackV2 from 0xd0bcefdf1e67ea85
11    import HWGarageTokenV2 from 0xd0bcefdf1e67ea85
12  
13
14transaction(saleItemID: UInt64, saleItemPrice: UFix64, customID: String?, commissionAmount: UFix64, expiry: UInt64, marketplacesAddress: [Address]) {
15    let tokenReceiver: Capability<&{FungibleToken.Receiver}>
16    let HWGarageCardV2Provider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
17    let storefront: auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront
18    var saleCuts: [NFTStorefrontV2.SaleCut]
19    var marketplacesCapability: [Capability<&{FungibleToken.Receiver}>]
20
21    prepare(acct: auth(BorrowValue, IssueStorageCapabilityController, PublishCapability, SaveValue, UnpublishCapability, Storage) &Account) {
22
23    
24    
25
26        // HWGaragePack
27   let packCollectionData: MetadataViews.NFTCollectionData = HWGaragePack.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
28     ?? panic("ViewResolver does not resolve NFTCollectionData view")
29
30   // exit if packCollection exists
31   if acct.storage.borrow<&HWGaragePack.Collection>(from: packCollectionData.storagePath) == nil {
32     // create a new empty packCollection for HWGaragePack
33     let packCollection: @{NonFungibleToken.Collection} <- HWGaragePack.createEmptyCollection(nftType: Type<@HWGaragePack.NFT>())
34
35     // save HWGaragePack packCollection to the account
36     acct.storage.save(<-packCollection, to: packCollectionData.storagePath)
37
38     // create a public capability for the HWGaragePack packCollection
39     acct.capabilities.unpublish(packCollectionData.publicPath) // remove any current pubCap
40     let packCollectionCap: Capability<&HWGaragePack.Collection> = acct.capabilities.storage.issue<&HWGaragePack.Collection>(packCollectionData.storagePath)
41     acct.capabilities.publish(packCollectionCap, at: packCollectionData.publicPath)
42   }
43
44   // HWGarageCard
45   let cardCollectionData: MetadataViews.NFTCollectionData = HWGarageCard.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
46     ?? panic("ViewResolver does not resolve NFTCollectionData view")
47
48   // exit if cardCollection exists
49   if acct.storage.borrow<&HWGarageCard.Collection>(from: cardCollectionData.storagePath) == nil {
50     // create a new empty cardCollection for HWGarageCard
51     let cardCollection: @{NonFungibleToken.Collection} <- HWGarageCard.createEmptyCollection(nftType: Type<@HWGarageCard.NFT>())
52
53     // save HWGarageCard cardCollection to the account
54     acct.storage.save(<-cardCollection, to: cardCollectionData.storagePath)
55
56     // create a public capability for the HWGarageCard cardCollection
57     acct.capabilities.unpublish(cardCollectionData.publicPath) // remove any current pubCap
58     let cardCollectionCap: Capability<&HWGarageCard.Collection> = acct.capabilities.storage.issue<&HWGarageCard.Collection>(cardCollectionData.storagePath)
59     acct.capabilities.publish(cardCollectionCap, at: cardCollectionData.publicPath)
60   }
61
62   // HWGarageTokenV2
63   let tokenCollectionDataV2: MetadataViews.NFTCollectionData = HWGarageTokenV2.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
64     ?? panic("ViewResolver does not resolve NFTCollectionData view")
65
66   if acct.storage.borrow<&HWGarageTokenV2.Collection>(from: tokenCollectionDataV2.storagePath) == nil {
67     // create a new empty tokenCollection for HWGarageTokenV2
68     let tokenCollection: @{NonFungibleToken.Collection} <- HWGarageTokenV2.createEmptyCollection(nftType: Type<@HWGarageTokenV2.NFT>())
69
70     // save HWGarageTokenV2 tokenCollection to the account
71     acct.storage.save(<-tokenCollection, to: tokenCollectionDataV2.storagePath)
72
73     // create a public capability for the HWGarageTokenV2 tokenCollection
74     acct.capabilities.unpublish(tokenCollectionDataV2.publicPath) // remove any current pubCap
75     let tokenCollectionCap = acct.capabilities.storage.issue<&HWGarageTokenV2.Collection>(tokenCollectionDataV2.storagePath)
76     acct.capabilities.publish(tokenCollectionCap, at: tokenCollectionDataV2.publicPath)
77   }
78
79   // HWGarageCardV2
80   let cardCollectionDataV2: MetadataViews.NFTCollectionData = HWGarageCardV2.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
81     ?? panic("ViewResolver does not resolve NFTCollectionData view")
82
83   // exit if cardCollection exists
84   if acct.storage.borrow<&HWGarageCardV2.Collection>(from: cardCollectionDataV2.storagePath) == nil {
85     // create a new empty cardCollection for HWGarageCardV2
86     let cardCollection: @{NonFungibleToken.Collection} <- HWGarageCardV2.createEmptyCollection(nftType: Type<@HWGarageCardV2.NFT>())
87
88     // save HWGarageCardV2 cardCollection to the account
89     acct.storage.save(<-cardCollection, to: cardCollectionDataV2.storagePath)
90
91     // create a public capability for the HWGarageCardV2 cardCollection
92     acct.capabilities.unpublish(cardCollectionDataV2.publicPath) // remove any current pubCap
93     let cardCollectionCap = acct.capabilities.storage.issue<&HWGarageCardV2.Collection>(cardCollectionDataV2.storagePath)
94     acct.capabilities.publish(cardCollectionCap, at: cardCollectionDataV2.publicPath)
95   }
96
97   // HWGaragePackV2
98   let garagePackCollectionDataV2: MetadataViews.NFTCollectionData = HWGaragePackV2.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
99     ?? panic("ViewResolver does not resolve NFTCollectionData view")
100
101   // exit if packCollection exists
102   if acct.storage.borrow<&HWGaragePackV2.Collection>(from: garagePackCollectionDataV2.storagePath) == nil {
103     // create a new empty packCollection for HWGaragePackV2
104     let packCollection: @{NonFungibleToken.Collection} <- HWGaragePackV2.createEmptyCollection(nftType: Type<@HWGaragePackV2.NFT>())
105
106     // save HWGaragePackV2 packCollection to the account
107     acct.storage.save(<-packCollection, to: garagePackCollectionDataV2.storagePath)
108
109     // create a public capability for the HWGaragePackV2 packCollection
110     acct.capabilities.unpublish(garagePackCollectionDataV2.publicPath) // remove any current pubCap
111     let packCollectionCap = acct.capabilities.storage.issue<&HWGaragePackV2.Collection>(garagePackCollectionDataV2.storagePath)
112     acct.capabilities.publish(packCollectionCap, at: garagePackCollectionDataV2.publicPath)
113   }
114
115
116    
117        if acct.storage.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil {
118
119            // Create a new empty Storefront
120            let storefront <- NFTStorefrontV2.createStorefront() as! @NFTStorefrontV2.Storefront
121
122            // save it to the account
123            acct.storage.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath)
124
125            // create a public capability for the Storefront
126            let storefrontPublicCap = acct.capabilities.storage.issue<&{NFTStorefrontV2.StorefrontPublic}>(
127                    NFTStorefrontV2.StorefrontStoragePath
128                )
129            acct.capabilities.publish(storefrontPublicCap, at: NFTStorefrontV2.StorefrontPublicPath)
130        }
131
132  
133
134        self.saleCuts = []
135        self.marketplacesCapability = []
136
137        let collectionData = HWGarageCardV2.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData?
138             ?? panic("ViewResolver does not resolve NFTCollectionData view")
139
140        // Receiver for the sale cut.
141        self.tokenReceiver = acct.capabilities.get<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)
142        assert(self.tokenReceiver.borrow() != nil, message: "Missing or mis-typed Flow receiver")
143
144        self.HWGarageCardV2Provider = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>(
145                collectionData.storagePath
146        )
147        assert(self.HWGarageCardV2Provider.check(), message: "Missing or mis-typed Collection provider")
148
149        let collection = acct.capabilities.borrow<&{NonFungibleToken.Collection}>(
150            collectionData.publicPath
151        ) ?? panic("Could not borrow a reference to the signer's collection")
152
153        var totalRoyaltyCut = 0.0
154        let effectiveSaleItemPrice = saleItemPrice - commissionAmount
155        // eslint-disable-next-line
156        let nft = collection.borrowNFT(saleItemID)!
157        // Check whether the NFT implements the MetadataResolver or not.
158        if nft.getViews().contains(Type<MetadataViews.Royalties>()) {
159            let royaltiesRef = nft.resolveView(Type<MetadataViews.Royalties>())?? panic("Unable to retrieve the royalties")
160            let royalties = (royaltiesRef as! MetadataViews.Royalties).getRoyalties()
161            for royalty in royalties {
162                // TODO - Verify the type of the vault and it should exists
163                let royaltyValue = royalty.cut * saleItemPrice
164                self.saleCuts.append(
165                    NFTStorefrontV2.SaleCut(
166                        receiver: royalty.receiver,
167                        amount: royaltyValue
168                    )
169                )
170                totalRoyaltyCut = totalRoyaltyCut + royaltyValue
171            }
172        }
173        // Append the cut for the seller.
174        self.saleCuts.append(
175            NFTStorefrontV2.SaleCut(
176                receiver: self.tokenReceiver,
177                amount: effectiveSaleItemPrice - totalRoyaltyCut
178            )
179        )
180        assert(self.HWGarageCardV2Provider.borrow() != nil, message: "Missing or mis-typed HWGarageCardV2.Collection provider")
181
182        self.storefront = acct.storage.borrow<auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront>(
183                from: NFTStorefrontV2.StorefrontStoragePath
184            ) ?? panic("Missing or mis-typed NFTStorefront Storefront")
185
186        for marketplace in marketplacesAddress {
187            // Here we are making a fair assumption that all given addresses would have
188            // the capability to receive the
189            self.marketplacesCapability.append(
190                getAccount(marketplace).capabilities.get<&{FungibleToken.Receiver}>(/public/flowTokenReceiver)
191            )
192        }
193    }
194
195    execute {
196        // Create listing
197        self.storefront.createListing(
198            nftProviderCapability: self.HWGarageCardV2Provider,
199            nftType: Type<@HWGarageCardV2.NFT>(),
200            nftID: saleItemID,
201            salePaymentVaultType: Type<@FlowToken.Vault>(),
202            saleCuts: self.saleCuts,
203            marketplacesCapability: self.marketplacesCapability.length == 0 ? nil : self.marketplacesCapability,
204            customID: customID,
205            commissionAmount: commissionAmount,
206            expiry: expiry
207        )
208    }
209}