Smart Contract

SomePlacePrimarySaleHelper

A.667a16294a089ef8.SomePlacePrimarySaleHelper

Deployed

2h ago
Feb 28, 2026, 09:22:11 PM UTC

Dependents

0 imports
1/*
2    Help manage a primary sale for SomePlace collectibles utilizing preminted NFTs that are in storage.
3    This is meant to be curated for specific drops where there are leftover NFTs to be sold publically from a private sale.
4*/
5import NonFungibleToken from 0x1d7e57aa55817448
6import SomePlaceCollectible from 0x667a16294a089ef8
7
8pub contract SomePlacePrimarySaleHelper {
9    access(self) let premintedNFTCap: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>
10    
11    access(account) fun retrieveAvailableNFT(): @SomePlaceCollectible.NFT {
12        let nftCollection = self.premintedNFTCap.borrow()!
13        let randomIndex = unsafeRandom() % UInt64(nftCollection.getIDs().length)
14        return <-(nftCollection.withdraw(withdrawID: nftCollection.getIDs()[randomIndex]) as! @SomePlaceCollectible.NFT)
15    }
16
17    pub fun getRemainingNFTCount(): Int {
18        return self.premintedNFTCap.borrow()!.getIDs().length
19    }
20
21    init() {
22        self.account.link<&SomePlaceCollectible.Collection>(/private/SomePlacePrimarySaleHelperAccess, target: SomePlaceCollectible.CollectionStoragePath)
23        self.premintedNFTCap = self.account.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>(/private/SomePlacePrimarySaleHelperAccess)
24    }
25}
26