MarketplaceSEALED

◆◆●▪╳▫@@╱○*&$●▓@◆▒○█░&▒░○@#░&^░?█▫▒~%░@!$$&*%●%█*!#╱░▒◆░!%#!○◆●█

Transaction ID

Timestamp

Sep 06, 2024, 05:03:59 AM UTC
1y ago

Block Height

86,128,631

Computation

0

Execution Fee

0.00001662 FLOW

Transaction Summary

Marketplace

Called FungibleToken, NonFungibleToken, DapperUtilityCoin +2 more

Script Arguments

0saleItemIDUInt64
7025724
1saleItemPriceUFix64
1.00000000

Cadence Script

1import FungibleToken from 0xf233dcee88fe0abe
2import NonFungibleToken from 0x1d7e57aa55817448
3import DapperUtilityCoin from 0xead892083b3e2c6c
4import AllDay from 0xe4cf4bdc1751c65d
5import NFTStorefront from 0x4eb8a10cb9f87357
6
7transaction(saleItemID: UInt64, saleItemPrice: UFix64) {
8    let ducReceiver: Capability<&{FungibleToken.Receiver}>
9    let royaltyReceiver: Capability<&{FungibleToken.Receiver}>
10    let AllDayNFTProvider: Capability<auth(NonFungibleToken.Withdraw) &AllDay.Collection>?
11    let storefront: auth(NFTStorefront.CreateListing) &NFTStorefront.Storefront
12
13    prepare(acct: auth(Storage, Capabilities) &Account) {
14        // If the account doesn't already have a Storefront
15        if acct.storage.borrow<&NFTStorefront.Storefront>(from: NFTStorefront.StorefrontStoragePath) == nil {
16
17            // Create a new empty .Storefront
18            let storefront <- NFTStorefront.createStorefront() as! @NFTStorefront.Storefront
19            
20            // save it to the account
21            acct.storage.save(<-storefront, to: NFTStorefront.StorefrontStoragePath)
22
23            // create a public capability for the .Storefront
24            acct.capabilities.publish(
25                acct.capabilities.storage.issue<&NFTStorefront.Storefront>(NFTStorefront.StorefrontStoragePath),
26                at: NFTStorefront.StorefrontPublicPath
27            )
28        }
29
30        self.ducReceiver = acct.capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)!
31            assert(self.ducReceiver.borrow() != nil, message: "Missing or mis-typed DUC receiver")
32        
33        self.royaltyReceiver = getAccount(0xe4cf4bdc1751c65d).capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)!
34            assert(self.royaltyReceiver.borrow() != nil, message: "Missing or mis-typed fungible token receiver for AllDay account")
35        
36        let AllDayNFTCollectionProviderPrivatePath = /storage/AllDayNFTCollectionProviderForNFTStorefront
37
38        // Temporary variable to handle capability assignment
39        var provider: Capability<auth(NonFungibleToken.Withdraw) &AllDay.Collection>? =
40            acct.storage.copy<Capability<auth(NonFungibleToken.Withdraw) &AllDay.Collection>>(from: AllDayNFTCollectionProviderPrivatePath)
41        
42        if provider == nil {
43            provider = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &AllDay.Collection>(AllDay.CollectionStoragePath)
44            acct.capabilities.storage.getController(byCapabilityID: provider!.id)!.setTag("AllDayNFTCollectionProviderForNFTStorefront")
45            // Save the capability to the account storage
46            acct.storage.save(provider!, to: AllDayNFTCollectionProviderPrivatePath)
47        }
48
49        self.AllDayNFTProvider = provider
50        assert(self.AllDayNFTProvider?.borrow() != nil, message: "Missing or mis-typed AllDay.Collection provider")
51
52        self.storefront = acct.storage.borrow<auth(NFTStorefront.CreateListing) &NFTStorefront.Storefront>(from: NFTStorefront.StorefrontStoragePath)
53            ?? panic("Missing or mis-typed NFTStorefront Storefront")
54    }
55
56    execute {
57        let saleCut = NFTStorefront.SaleCut(
58            receiver: self.ducReceiver,
59            amount: saleItemPrice * 0.95
60        )
61        let royaltyCut = NFTStorefront.SaleCut(
62            receiver: self.royaltyReceiver,
63            amount: saleItemPrice * 0.05
64        )
65        self.storefront.createListing(
66            nftProviderCapability: self.AllDayNFTProvider!,
67            nftType: Type<@AllDay.NFT>(),
68            nftID: saleItemID,
69            salePaymentVaultType: Type<@DapperUtilityCoin.Vault>(),
70            saleCuts: [saleCut, royaltyCut]
71        )
72    }
73}