TransactionSEALED
╱□#╱▪◇~$@▒!██~░●%▒●□▒◇●▓░■~^▒!╳&$◇○◇██░!?■▫■░░◇*&●!■╲╱○?@^▓░▒!▒#
Transaction ID
Transaction Summary
Contract CallCalled FungibleToken, TopShotMarketV3, TopShot +1 more
Script Arguments
Cadence Script
1import FungibleToken from 0xf233dcee88fe0abe
2import TopShotMarketV3 from 0xc1e4f4f4c4257510
3import TopShot from 0x0b2a3299cc857e29
4import Market from 0xc1e4f4f4c4257510
5
6transaction() {
7
8 prepare(acct: AuthAccount) {
9
10 // check if moment is currently listed
11 var listed = false
12 if let marketV3CollectionRef = acct.getCapability(/public/topshotSalev3Collection)
13 .borrow<&{Market.SalePublic}>() {
14
15 let salePrice = marketV3CollectionRef.getPrice(tokenID: UInt64(44195299))
16
17 if salePrice != nil {
18 listed = true
19 }
20 } else if let marketV1CollectionRef = acct.getCapability(/public/topshotSaleCollection)
21 .borrow<&{Market.SalePublic}>() {
22
23 let salePrice = marketV1CollectionRef.getPrice(tokenID: UInt64(44195299))
24
25 if salePrice != nil {
26 listed = true
27 }
28 }
29 if listed {
30 panic("moment is already listed for sale")
31 }
32
33 // check to see if a v3 sale collection already exists
34 if acct.borrow<&TopShotMarketV3.SaleCollection>(from: TopShotMarketV3.marketStoragePath) == nil {
35 // get the fungible token capabilities for the owner and beneficiary
36 let ownerCapability = acct.getCapability<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
37 let beneficiaryCapability = getAccount(0xfaf0cc52c6e3acaf).getCapability<&{FungibleToken.Receiver}>(/public/dapperUtilityCoinReceiver)
38
39 let ownerCollection = acct.link<&TopShot.Collection>(/private/MomentCollection, target: /storage/MomentCollection)!
40
41 // get a capability for the v1 collection
42 var v1SaleCollection: Capability<&Market.SaleCollection>? = nil
43 if acct.borrow<&Market.SaleCollection>(from: /storage/topshotSaleCollection) != nil {
44 v1SaleCollection = acct.link<&Market.SaleCollection>(/private/topshotSaleCollection, target: /storage/topshotSaleCollection)!
45 }
46
47 // create a new sale collection
48 let topshotSaleCollection <- TopShotMarketV3.createSaleCollection(ownerCollection: ownerCollection,
49 ownerCapability: ownerCapability,
50 beneficiaryCapability: beneficiaryCapability,
51 cutPercentage: 0.050000,
52 marketV1Capability: v1SaleCollection)
53
54 // save it to storage
55 acct.save(<-topshotSaleCollection, to: TopShotMarketV3.marketStoragePath)
56
57 // create a public link to the sale collection
58 acct.link<&TopShotMarketV3.SaleCollection{Market.SalePublic}>(TopShotMarketV3.marketPublicPath, target: TopShotMarketV3.marketStoragePath)
59 }
60
61 // borrow a reference to the sale
62 let topshotSaleCollection = acct.borrow<&TopShotMarketV3.SaleCollection>(from: TopShotMarketV3.marketStoragePath)
63 ?? panic("Could not borrow from sale in storage")
64
65 // put the moment up for sale
66 topshotSaleCollection.listForSale(tokenID: 44195299, price: UFix64(5))
67
68 }
69}