Skip to main content

Mint Phase DTO

Schema for mint phase definitions used in drop APIs.

Description

The Mint Phase DTO schema defines the structure of mint phase information for NFT drops, including phase name, pricing, and currency information.

Class Validator Schema

import { IsNumber, IsString } from "class-validator";

export class MintPhaseDto {
@IsString()
name: string;

@IsNumber()
price: number;

@IsString()
currency: string;
}

TypeScript Type

interface MintPhaseDto {
name: string;
price: number;
currency: string;
}

Example

{
"name": "Early Bird",
"price": 0.05,
"currency": "ETH"
}

Field Descriptions

FieldTypeRequiredDescription
namestringYesPhase name
pricenumberYesPhase price
currencystringYesPrice currency

Example Response

{
"id": "phase-1",
"name": "Whitelist",
"startDate": 1640995200000,
"endDate": 1641081600000
}

Field Descriptions

FieldTypeRequiredDescription
idstringYesUnique identifier for the minting phase
namestringYesHuman-readable phase name
startDatenumberYesPhase start timestamp in milliseconds
endDatenumberYesPhase end timestamp in milliseconds

Common Minting Phases

Typical minting phase names include:

  • Whitelist: Early access for whitelisted addresses
  • Public: Open minting for everyone
  • VIP: Exclusive minting for VIP members
  • Presale: Early sale before public launch
  • Dutch Auction: Decreasing price auction
  • Fixed Price: Standard fixed price minting

Usage Example

// Example minting phase configuration
const mintPhases = [
{
id: "phase-1",
name: "Whitelist",
startDate: 1640995200000, // Jan 1, 2022 00:00:00 UTC
endDate: 1641081600000, // Jan 2, 2022 00:00:00 UTC
},
{
id: "phase-2",
name: "Public",
startDate: 1641081600000, // Jan 2, 2022 00:00:00 UTC
endDate: 1641254400000, // Jan 4, 2022 00:00:00 UTC
},
];

// Check if a phase is currently active
const isPhaseActive = (phase, currentTime = Date.now()) => {
return currentTime >= phase.startDate && currentTime <= phase.endDate;
};

// Get current active phase
const getCurrentPhase = () => {
return mintPhases.find((phase) => isPhaseActive(phase));
};

const currentPhase = getCurrentPhase();
if (currentPhase) {
console.log("Current phase:", currentPhase.name);
} else {
console.log("No active minting phase");
}

Validation Rules

  • id: Must be a unique string identifier
  • name: Must be a non-empty string
  • startDate: Must be a valid timestamp
  • endDate: Must be after startDate
  • Timing: Phases should not overlap (enforced by business logic)

Phase Scheduling Best Practices

  1. Sequential Phases: Ensure phases don't overlap
  2. Clear Naming: Use descriptive names for each phase
  3. Adequate Duration: Give users enough time to mint
  4. Buffer Time: Include small gaps between phases if needed

Next Steps