# Quickstart

Request a [partner key](https://docs.deads.io/guides/keys.md) scoped to your collections and application origins, then install the SDK:

```bash
npm i @solanadeads/gravemint
```

The package includes TypeScript types and supports ESM and CommonJS.

## Read a drop

```ts
import { GraveMintClient } from '@solanadeads/gravemint';

const gm = new GraveMintClient({ apiKey: 'gm_pub_…' });
const drop = await gm.v1.collection('deads');

// drop.collection     — name, image, chain and socials
// drop.stats          — totalSupply, mintedCount, availableCount, percentMinted
// drop.phases.active  — array of active phases
// drop.serverTime     — server timestamp for countdowns
```

The collection read accepts a short ID, UUID or on-chain address. Prefer the short ID for public URLs and preserve address case.

## Render the price correctly

Read the phase's `priceDisplay` and handle each `kind`:

```ts
const phase = drop.phases.active[0];
const p = phase?.priceDisplay;
const label = p?.kind === 'amount'
  ? (p.isFree ? 'Free' : `${p.amount} ${p.currency}`)
  : p?.kind === 'range'
    ? `${p.min}–${p.max} ${p.currency}`
    : p?.kind === 'hidden'
      ? 'Price revealed when you qualify'
      : 'See on GraveMint';
```

This example selects the first active phase. If a collection has several, let the collector choose the appropriate phase. Display `hidden` and `unknown` without assigning them a zero price.

## Mint

Use a [base64 signer](https://docs.deads.io/guides/signing.md#the-interface) to connect your wallet library. `mint()` coordinates preparation, signing and server submission:

```ts
import { MintOutcomeUnknownError, type TransactionSigner } from '@solanadeads/gravemint';

async function mintOne(signer: TransactionSigner, walletAddress: string) {
  if (!drop.capabilities.supportedBySurface || !phase) {
    throw new Error('Open the hosted mint page for this collection.');
  }

  try {
    const result = await gm.mint.mint({
      collectionId: drop.collection.id,
      phaseId: phase.id,
      walletAddress,
      quantity: 1,
      signer,
    });
    return result;
  } catch (error) {
    if (error instanceof MintOutcomeUnknownError) {
      // Save error.sessionIds and check the wallet before allowing another mint.
      // The submitted transaction may still complete.
    }
    throw error;
  }
}
```

The wallet signs the prepared bytes; GraveMint validates and broadcasts them. Pass signed transactions to the SDK rather than broadcasting them with your wallet library. See [wallets and signing](https://docs.deads.io/guides/signing.md) for the manual flow, batch results and session handling.

## Supported features {#when-you-cannot-render-a-drop-faithfully}

Check the collection's capabilities before enabling the mint flow. For collections that require features outside the core surface, offer the hosted mint page:

```tsx
if (!drop.capabilities.supportedBySurface) {
  return drop.capabilities.mintUrl
    ? <a href={drop.capabilities.mintUrl}>Mint on GraveMint</a>
    : <p>This collection is not available through this integration.</p>;
}
```

## Next

- [The read model](https://docs.deads.io/concepts/read-model.md): phases, prices, eligibility and wallet limits.
- [Wallets and signing](https://docs.deads.io/guides/signing.md): signer adapters, submission and batch outcomes.
- [React mint panel](https://docs.deads.io/recipes/react.md): a component example to adapt to your application.
- [Keys and origins](https://docs.deads.io/guides/keys.md): browser and server configuration.
- [Errors](https://docs.deads.io/guides/errors.md) and [troubleshooting](https://docs.deads.io/guides/troubleshooting.md): response codes and recovery steps.
- [SDK reference](https://docs.deads.io/sdk/gravemint-reference.md), [v1 API](https://docs.deads.io/api/gravemint-v1.md) and [MCP server](https://docs.deads.io/tools/mcp.md).

---
Source: https://docs.deads.io/guides/quickstart
Markdown: https://docs.deads.io/guides/quickstart.md
