Smart Contract

SoulMade

A.9a57dfe5c8ce609c.SoulMade

Deployed

2h ago
Feb 28, 2026, 06:38:20 PM UTC

Dependents

0 imports
1import NonFungibleToken from 0x1d7e57aa55817448
2import NFTStorefront from 0x4eb8a10cb9f87357
3import SoulMadeComponent from 0x9a57dfe5c8ce609c
4import SoulMadeMain from 0x9a57dfe5c8ce609c
5import SoulMadePack from 0x9a57dfe5c8ce609c
6import SoulMadeMarketplace from 0x9a57dfe5c8ce609c
7import FungibleToken from 0xf233dcee88fe0abe
8import FlowToken from 0x1654653399040a61
9
10pub contract SoulMade {
11
12  pub let AdminStoragePath: StoragePath
13
14  pub resource Admin {
15
16    pub fun mintComponent(series: String,
17                                    name: String,
18                                    description: String,
19                                    category: String,
20                                    layer: UInt64,
21                                    edition: UInt64,
22                                    maxEdition: UInt64,
23                                    ipfsHash: String) {
24
25      let adminComponentsCollection = SoulMade.account.borrow<&SoulMadeComponent.Collection{NonFungibleToken.CollectionPublic}>(from: SoulMadeComponent.CollectionStoragePath)!
26      
27      var newNFT <- SoulMadeComponent.makeEdition(
28          series: series,
29          name: name,
30          description: description,
31          category: category,
32          layer: layer,
33          currentEdition: edition,
34          maxEdition: maxEdition,
35          ipfsHash: ipfsHash
36      )
37      adminComponentsCollection.deposit(token: <- newNFT)
38    }
39
40    pub fun mintComponents(series: String,
41                                    name: String,
42                                    description: String,
43                                    category: String,
44                                    layer: UInt64,
45                                    startEdition: UInt64,
46                                    endEdition: UInt64,
47                                    maxEdition: UInt64,
48                                    ipfsHash: String) {
49
50      let adminComponentsCollection = SoulMade.account.borrow<&SoulMadeComponent.Collection{NonFungibleToken.CollectionPublic}>(from: SoulMadeComponent.CollectionStoragePath)!
51      
52      var edition = startEdition
53
54      while edition <= endEdition {
55        var newNFT <- SoulMadeComponent.makeEdition(
56            series: series,
57            name: name,
58            description: description,
59            category: category,
60            layer: layer,
61            currentEdition: edition,
62            maxEdition: maxEdition,
63            ipfsHash: ipfsHash
64        )
65        edition = edition + UInt64(1)
66        adminComponentsCollection.deposit(token: <- newNFT)
67      }
68    }
69
70    pub fun moveMainComponentToPack(scarcity: String, series: String, ipfsHash: String, mainNftIds: [UInt64], componentNftIds: [UInt64], adminStoragePath: StoragePath) {
71      let adminMainCollection = SoulMade.account.borrow<&SoulMadeMain.Collection>(from: SoulMadeMain.CollectionStoragePath)!
72      let adminComponentCollection = SoulMade.account.borrow<&SoulMadeComponent.Collection>(from: SoulMadeComponent.CollectionStoragePath)!
73      let adminPackCollection = SoulMade.account.borrow<&SoulMadePack.Collection{NonFungibleToken.CollectionPublic}>(from: adminStoragePath)!
74
75      var mainNftList: @[SoulMadeMain.NFT] <- []
76      var componentNftList: @[SoulMadeComponent.NFT] <- []
77
78      for mainNftId in mainNftIds{
79        var nft <- adminMainCollection.withdraw(withdrawID: mainNftId) as! @SoulMadeMain.NFT
80        mainNftList.append(<- nft)
81      }
82
83      for componentNftId in componentNftIds{
84        var nft <- adminComponentCollection.withdraw(withdrawID: componentNftId) as! @SoulMadeComponent.NFT
85        componentNftList.append(<- nft)
86      }
87
88      var packNft <- SoulMadePack.mintPack(scarcity: scarcity, series: series, ipfsHash: ipfsHash, mainNfts: <- mainNftList, componentNfts: <- componentNftList)
89      adminPackCollection.deposit(token: <- packNft)      
90    }
91    
92    pub fun mintPackManually(scarcity: String, series: String, ipfsHash: String, mainNftIds: [UInt64], componentNftIds: [UInt64]) {
93      self.moveMainComponentToPack(scarcity: scarcity, series: series, ipfsHash: ipfsHash, mainNftIds: mainNftIds, componentNftIds: componentNftIds, adminStoragePath: SoulMadePack.CollectionStoragePath)
94    }
95
96    pub fun mintPackFreeClaim(scarcity: String, series: String, ipfsHash: String, mainNftIds: [UInt64], componentNftIds: [UInt64]) {
97      self.moveMainComponentToPack(scarcity: scarcity, series: series, ipfsHash: ipfsHash, mainNftIds: mainNftIds, componentNftIds: componentNftIds, adminStoragePath: SoulMadePack.CollectionFreeClaimStoragePath)
98    }
99
100    pub fun renewFreeClaim() {
101      SoulMadePack.renewClaimDictionary()
102    }
103
104    pub fun updataAccountFreeClaim(address: Address, series: String) {
105      SoulMadePack.updateClaimDictionary(address: address, series: series)
106    }
107
108    pub fun updataPlatformCut(platformCut: UFix64) {
109      SoulMadeMarketplace.updatePlatformCut(platformCut: platformCut)
110    }
111
112  }
113
114  pub fun getMainCollectionIds(address: Address) : [UInt64] {
115      let receiverRef = getAccount(address)
116                        .getCapability<&{SoulMadeMain.CollectionPublic}>(SoulMadeMain.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
117      return receiverRef.getIDs()
118  }
119
120  pub fun getMainDetail(address: Address, mainNftId: UInt64) : SoulMadeMain.MainDetail {
121    let receiverRef = getAccount(address)
122                      .getCapability<&{SoulMadeMain.CollectionPublic}>(SoulMadeMain.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
123    return receiverRef.borrowMain(id: mainNftId).mainDetail
124  }
125
126  pub fun getComponentCollectionIds(address: Address) : [UInt64] {
127    let receiverRef = getAccount(address)
128                      .getCapability<&{SoulMadeComponent.CollectionPublic}>(SoulMadeComponent.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
129    return receiverRef.getIDs()
130  }
131
132  pub fun getComponentDetail(address: Address, componentNftId: UInt64) : SoulMadeComponent.ComponentDetail {
133      let receiverRef = getAccount(address)
134                        .getCapability<&{SoulMadeComponent.CollectionPublic}>(SoulMadeComponent.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
135      return receiverRef.borrowComponent(id : componentNftId).componentDetail
136  }
137
138  pub fun getPackCollectionIds(address: Address) : [UInt64] {
139      let receiverRef = getAccount(address)
140                        .getCapability<&{SoulMadePack.CollectionPublic}>(SoulMadePack.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
141      return receiverRef.getIDs()
142  }
143
144  pub fun getPackDetail(address: Address, packNftId: UInt64) : SoulMadePack.PackDetail {
145      let receiverRef = getAccount(address)
146                        .getCapability<&{SoulMadePack.CollectionPublic}>(SoulMadePack.CollectionPublicPath).borrow() ?? panic("Could not borrow the receiver reference")
147      return receiverRef.borrowPack(id : packNftId).packDetail
148  }
149
150  pub fun getPackListingIdsPerSeries(address: Address): {String: [UInt64]} {
151      let storefrontRef = getAccount(address)
152          .getCapability<&NFTStorefront.Storefront{NFTStorefront.StorefrontPublic}>(NFTStorefront.StorefrontPublicPath)
153          .borrow()
154          ?? panic("Could not borrow public storefront from address")
155      
156      var res: {String: [UInt64]} = {}
157
158      for listingID in storefrontRef.getListingIDs() {
159          var listingDetail : NFTStorefront.ListingDetails = storefrontRef.borrowListing(listingResourceID: listingID)!.getDetails()
160          if listingDetail.purchased == false && listingDetail.nftType == Type<@SoulMadePack.NFT>() {
161            var packNftId = listingDetail.nftID
162            var packDetail: SoulMadePack.PackDetail = SoulMade.getPackDetail(address: address, packNftId: packNftId)!
163            var packSeries = packDetail.series
164            if res[packSeries] == nil{
165              res[packSeries] = [listingID]
166            } else {
167              res[packSeries]!.append(listingID)
168            }
169          }
170      }
171
172      return res
173  }
174
175
176  init() {
177    self.AdminStoragePath = /storage/SoulMadeAdmin
178    self.account.save(<- create Admin(), to: self.AdminStoragePath)
179  }
180
181}