MarketplaceSEALED

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

Transaction ID

Timestamp

Jul 10, 2024, 05:11:56 PM UTC
1y ago

Block Height

82,137,192

Computation

0

Execution Fee

0.00000514 FLOW

Proposerseq:2 key:12

Authorizers

1

Transaction Summary

Marketplace

Called FungibleToken, NonFungibleToken, DapperUtilityCoin +2 more

Script Arguments

0saleItemIDUInt64
539944
1saleItemPriceUFix64
2.00000000
2royaltyPercentUFix64
0.05000000

Cadence Script

1import FungibleToken from 0xf233dcee88fe0abe
2import NonFungibleToken from 0x1d7e57aa55817448
3import DapperUtilityCoin from 0xead892083b3e2c6c
4import UFC_NFT from 0x329feb3ab062d289
5import NFTStorefront from 0x4eb8a10cb9f87357
6
7transaction(saleItemID: UInt64, saleItemPrice: UFix64, royaltyPercent: UFix64) {
8    let sellerPaymentReceiver: Capability<&{FungibleToken.Receiver}>
9    let UFC_NFTProvider: Capability<&UFC_NFT.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
10    let storefront: &NFTStorefront.Storefront
11
12    prepare(acct: AuthAccount) {
13        // If the account doesn't already have a Storefront
14        if acct.borrow<&NFTStorefront.Storefront>(from: NFTStorefront.StorefrontStoragePath) == nil {
15
16            // Create a new empty .Storefront
17            let newstorefront <- NFTStorefront.createStorefront() as! @NFTStorefront.Storefront
18            
19            // save it to the account
20            acct.save(<-newstorefront, to: NFTStorefront.StorefrontStoragePath)
21
22            // create a public capability for the .Storefront
23            acct.link<&NFTStorefront.Storefront{NFTStorefront.StorefrontPublic}>(
24                NFTStorefront.StorefrontPublicPath,
25                target: NFTStorefront.StorefrontStoragePath
26            )
27        }
28
29        // We need a provider capability, but one is not provided by default so we create one if needed.
30        let UFC_NFTCollectionProviderPrivatePath = /private/UFC_NFTCollectionProviderForNFTStorefront
31
32        self.sellerPaymentReceiver = acct.getCapability<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
33        assert(self.sellerPaymentReceiver.borrow() != nil, message: "Missing or mis-typed DapperUtilityCoin receiver")
34
35        if !acct.getCapability<&UFC_NFT.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
36        (UFC_NFTCollectionProviderPrivatePath)!.check() {
37            acct.link<&UFC_NFT.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
38            (UFC_NFTCollectionProviderPrivatePath, target: UFC_NFT.CollectionStoragePath)
39        }
40
41        self.UFC_NFTProvider = acct.getCapability<&UFC_NFT.Collection{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(UFC_NFTCollectionProviderPrivatePath)!
42        assert(self.UFC_NFTProvider.borrow() != nil, message: "Missing or mis-typed UFC_NFT.Collection provider")
43
44        self.storefront = acct.borrow<&NFTStorefront.Storefront>(from: NFTStorefront.StorefrontStoragePath)
45            ?? panic("Missing or mis-typed NFTStorefront Storefront")
46    }
47
48    execute {
49        let amountSeller = saleItemPrice * (1.0 - royaltyPercent)
50        let amountRoyalty = saleItemPrice - amountSeller
51
52        // Get the royalty recipient's public account object
53        let royaltyRecipient = getAccount(0xcfa0d15914188d1d)
54
55        // Get a reference to the royalty recipient's Receiver
56        let royaltyReceiverRef = royaltyRecipient.getCapability<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
57        assert(royaltyReceiverRef.borrow() != nil, message: "Missing or mis-typed DapperUtilityCoin royalty receiver")
58
59        let saleCutSeller = NFTStorefront.SaleCut(
60            receiver: self.sellerPaymentReceiver,
61            amount: amountSeller
62        )
63
64        let saleCutRoyalty = NFTStorefront.SaleCut(
65            receiver: royaltyReceiverRef,
66            amount: amountRoyalty
67        )
68
69        self.storefront.createListing(
70            nftProviderCapability: self.UFC_NFTProvider,
71            nftType: Type<@UFC_NFT.NFT>(),
72            nftID: saleItemID,
73            salePaymentVaultType: Type<@DapperUtilityCoin.Vault>(),
74            saleCuts: [saleCutSeller, saleCutRoyalty]
75        )
76    }
77}