MarketplaceSEALED
▓╲$○▫╱?@$░○~&●?~╱■╳▒╳█□~$@&╳▓░!%*~╲▓◆▓@█%□◆▓◆╳&○■□~▪?$▪◆■▪%●$▓!●
Transaction ID
Execution Fee
0.0027 FLOWTransaction Summary
MarketplaceCalled FungibleToken, NonFungibleToken, MetadataViews +5 more
Script Arguments
Cadence Script
1import FungibleToken from 0xf233dcee88fe0abe
2import NonFungibleToken from 0x1d7e57aa55817448
3import MetadataViews from 0x1d7e57aa55817448
4import TokenForwarding from 0xe544175ee0461c4b
5import DapperUtilityCoin from 0xead892083b3e2c6c
6import PackNFT from 0x0b2a3299cc857e29
7import IPackNFT from 0x18ddf0823a55a0ee
8import NFTStorefrontV2 from 0x4eb8a10cb9f87357
9
10/// Transaction that lists packNFTs for sale in Storefront.
11transaction() {
12 var ftReceiver: Capability<&{FungibleToken.Receiver}>?
13 var nftProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>?
14 let collectionRef: &PackNFT.Collection
15 let storefront: auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront
16 /// ''customID'' - Optional string to represent identifier of the dapp.
17 let customID: String
18 /// ''commissionAmount'' - Commission amount that will be taken away by the purchase facilitator i.e marketplacesAddress.
19 let commissionAmount: UFix64
20 // we only ever want to use DapperUtilityCoin
21 let universalDucReceiver: Address
22
23 prepare(acct: auth(Storage, Capabilities) &Account) {
24 /// ''customID'' - Optional string to represent identifier of the dapp.
25 self.customID = "DAPPER_MARKETPLACE"
26 /// ''commissionAmount'' - Commission amount that will be taken away by the purchase facilitator i.e marketplacesAddress.
27 self.commissionAmount = 0.0
28 // we only ever want to use DapperUtilityCoin
29 self.universalDucReceiver = 0xead892083b3e2c6c
30
31 // ************************* Handling of DUC Recevier *************************** //
32
33 // Fetch the capability of the universal DUC receiver
34 let recipient = getAccount(self.universalDucReceiver).capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)!
35 assert(recipient.borrow() != nil, message: "Missing or mis-typed Fungible Token receiver for the DUC recipient")
36
37 self.ftReceiver = acct.capabilities.get<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
38
39
40 // *************************** Seller account interactions *************************** //
41 // This checks for the public capability
42 if !acct.capabilities.get<&PackNFT.Collection>(PackNFT.CollectionPublicPath)!.check() {
43 acct.capabilities.unpublish(PackNFT.CollectionPublicPath)
44 acct.capabilities.publish(
45 acct.capabilities.storage.issue<&PackNFT.Collection>(PackNFT.CollectionStoragePath),
46 at: PackNFT.CollectionPublicPath
47 )
48 }
49
50 self.nftProvider = acct.storage.copy<Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>>(from: /storage/PackNFTCollectionStorageCap)
51
52 if self.nftProvider == nil {
53 self.nftProvider = acct.capabilities.storage.issue<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>(PackNFT.CollectionStoragePath)
54 acct.storage.save(self.nftProvider!, to: /storage/PackNFTCollectionStorageCap)
55 }
56
57 self.collectionRef = acct.capabilities.borrow<&PackNFT.Collection>(PackNFT.CollectionPublicPath)
58 ?? panic("Could not borrow a reference to the collection")
59
60 if acct.storage.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil {
61 // Create a new empty Storefront
62 let storefront <- NFTStorefrontV2.createStorefront() as! @NFTStorefrontV2.Storefront
63 // save it to the account
64 acct.storage.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath)
65 // create a public capability for the Storefront
66 acct.capabilities.publish(
67 acct.capabilities.storage.issue<&NFTStorefrontV2.Storefront>(NFTStorefrontV2.StorefrontStoragePath),
68 at: NFTStorefrontV2.StorefrontPublicPath
69 )
70 }
71 self.storefront = acct.storage.borrow<auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath)!
72 }
73
74 execute {
75 let packNFTIDs = [184717955939637]
76 let saleItemPrices = [4.00000000]
77 for index, packNftID in packNFTIDs {
78 var totalRoyaltyCut = 0.0
79 let effectiveSaleItemPrice = UFix64(saleItemPrices[index])
80 var saleCuts: [NFTStorefrontV2.SaleCut] = []
81
82 let nft = self.collectionRef.borrowNFT(UInt64(packNftID))!
83
84 // Check whether the NFT implements the MetadataResolver or not.
85 if nft.getViews().contains(Type<MetadataViews.Royalties>()) {
86 let royaltiesRef = nft.resolveView(Type<MetadataViews.Royalties>()) ?? panic("Unable to retrieve the royalties")
87 let royalties = (royaltiesRef as! MetadataViews.Royalties).getRoyalties()
88 for royalty in royalties {
89 saleCuts.append(NFTStorefrontV2.SaleCut(receiver: royalty.receiver, amount: royalty.cut * effectiveSaleItemPrice))
90 totalRoyaltyCut = totalRoyaltyCut + royalty.cut * effectiveSaleItemPrice
91 }
92 }
93
94 // Append the cut for the seller.
95 saleCuts.append(NFTStorefrontV2.SaleCut(
96 receiver: self.ftReceiver!,
97 amount: effectiveSaleItemPrice - totalRoyaltyCut
98 ))
99
100 // create listing
101 self.storefront.createListing(
102 nftProviderCapability: self.nftProvider!,
103 nftType: Type<@PackNFT.NFT>(),
104 nftID: UInt64(packNftID),
105 salePaymentVaultType: Type<@DapperUtilityCoin.Vault>(),
106 saleCuts: saleCuts,
107 marketplacesCapability: nil,
108 customID: self.customID,
109 commissionAmount: self.commissionAmount,
110 expiry: 32503708800 // year 3000
111 )
112 }
113 }
114}