Smart Contract
DropFactory
A.befbaccb5032a457.DropFactory
1import FungibleToken from 0xf233dcee88fe0abe
2import MetadataViews from 0x1d7e57aa55817448
3
4import FlowtyDrops from 0xbefbaccb5032a457
5import FlowtyActiveCheckers from 0xbefbaccb5032a457
6import FlowtyAddressVerifiers from 0xbefbaccb5032a457
7import FlowtyPricers from 0xbefbaccb5032a457
8
9/*
10The DropFactory is a contract that helps create common types of drops
11*/
12access(all) contract DropFactory {
13 access(all) fun createEndlessOpenEditionDrop(
14 price: UFix64,
15 paymentTokenType: Type,
16 dropDisplay: MetadataViews.Display,
17 minterCap: Capability<&{FlowtyDrops.Minter}>,
18 nftTypeIdentifier: String
19 ): @FlowtyDrops.Drop {
20 pre {
21 paymentTokenType.isSubtype(of: Type<@{FungibleToken.Vault}>()): "paymentTokenType must be a FungibleToken"
22 }
23
24 // This drop is always on and never ends.
25 let activeChecker = FlowtyActiveCheckers.AlwaysOn()
26
27 // All addresses are allowed to participate
28 let addressVerifier = FlowtyAddressVerifiers.AllowAll(maxPerMint: 10)
29
30 // The cost of each mint is the same, and only permits one token type as payment
31 let pricer = FlowtyPricers.FlatPrice(price: price, paymentTokenType: paymentTokenType)
32
33 let phaseDetails = FlowtyDrops.PhaseDetails(activeChecker: activeChecker, display: nil, pricer: pricer, addressVerifier: addressVerifier)
34 let phase <- FlowtyDrops.createPhase(details: phaseDetails)
35
36
37 let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
38 let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier, paymentTokenTypes: {paymentTokenType.identifier: true})
39 let drop <- FlowtyDrops.createDrop(details: dropDetails, minterCap: minterCap, phases: <- [<-phase])
40
41 return <- drop
42 }
43
44 access(all) fun createTimeBasedOpenEditionDrop(
45 price: UFix64,
46 paymentTokenType: Type,
47 dropDisplay: MetadataViews.Display,
48 minterCap: Capability<&{FlowtyDrops.Minter}>,
49 startUnix: UInt64?,
50 endUnix: UInt64?,
51 nftTypeIdentifier: String
52 ): @FlowtyDrops.Drop {
53 pre {
54 paymentTokenType.isSubtype(of: Type<@{FungibleToken.Vault}>()): "paymentTokenType must be a FungibleToken"
55 }
56
57 // This ActiveChecker turns on at a set unix timestamp (or is on by default if nil), and ends at the specified end date if provided
58 let activeChecker = FlowtyActiveCheckers.TimestampChecker(start: startUnix, end: endUnix)
59
60 // All addresses are allowed to participate
61 let addressVerifier = FlowtyAddressVerifiers.AllowAll(maxPerMint: 10)
62
63 // The cost of each mint is the same, and only permits one token type as payment
64 let pricer = FlowtyPricers.FlatPrice(price: price, paymentTokenType: paymentTokenType)
65
66 let phaseDetails = FlowtyDrops.PhaseDetails(activeChecker: activeChecker, display: nil, pricer: pricer, addressVerifier: addressVerifier)
67 let phase <- FlowtyDrops.createPhase(details: phaseDetails)
68
69 let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
70 let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier, paymentTokenTypes: {paymentTokenType.identifier: true})
71 let drop <- FlowtyDrops.createDrop(details: dropDetails, minterCap: minterCap, phases: <- [<-phase])
72
73 return <- drop
74 }
75}