npm package: @pumpfunv2/sdk
Description: Official SDK for PumpFunV2 token launchpad - launch tokens programmatically with multiple automation modes
Author: PumpFunV2
Latest version: 1.0.0

# @pumpfunv2/sdk

Official SDK for PumpFunV2 token launchpad. Launch Solana tokens programmatically with multiple automation modes.

## Installation

```bash
npm install @pumpfunv2/sdk
# or
yarn add @pumpfunv2/sdk
# or
pnpm add @pumpfunv2/sdk
```

## Quick Start

```typescript
import { PumpFunV2Client } from '@pumpfunv2/sdk';

const client = new PumpFunV2Client({
  apiKey: 'pk_your_api_key_here'
});

// Launch a token
const result = await client.launch({
  name: 'My Token',
  symbol: 'MTK',
  description: 'My awesome token',
  mode: 'flywheel',
  creatorWalletPrivateKey: 'your_wallet_private_key'
});

console.log('Token launched:', result.mintAddress);
console.log('View on pump.fun:', result.pumpFunUrl);
```

## Launch Modes

| Mode | Description |
|------|-------------|
| `normal` | Standard launch with no automation |
| `flywheel` | Auto-buys tokens with claimed creator fees |
| `burn` | Burns tokens using creator fees |
| `distribution` | Distributes tokens to holders |
| `jackpot` | Random holder wins accumulated fees |
| `xprotected` | Requires X (Twitter) verification |
| `multi` | Split fees across multiple automation types |

## Usage Examples

### Normal Launch

```typescript
const result = await client.launch({
  name: 'My Token',
  symbol: 'MTK',
  description: 'A simple token launch',
  mode: 'normal',
  creatorWalletPrivateKey: 'your_key',
  initialBuyAmount: 0.1 // Optional: buy tokens at launch
});
```

### Flywheel Launch

```typescript
const result = await client.launch({
  name: 'Flywheel Token',
  symbol: 'FLY',
  description: 'Auto-buying flywheel token',
  mode: 'flywheel',
  flywheelPercentage: 75, // 75% of fees go to auto-buy
  creatorWalletPrivateKey: 'your_key'
});
```

### Distribution Launch

```typescript
const result = await client.launch({
  name: 'Distribution Token',
  symbol: 'DIST',
  description: 'Rewards all holders',
  mode: 'distribution',
  distributionPercentage: 50,
  minHoldersForDistribution: 10,
  creatorWalletPrivateKey: 'your_key'
});
```

### Multi-Mode Launch

```typescript
const result = await client.launch({
  name: 'Multi Token',
  symbol: 'MULTI',
  description: 'Split automation modes',
  mode: 'multi',
  allocations: [
    { mode: 'flywheel', percentage: 40 },
    { mode: 'burn', percentage: 30 },
    { mode: 'distribution', percentage: 30 }
  ],
  creatorWalletPrivateKey: 'your_key'
});
```

## React Components

The SDK includes ready-to-use React components for easy integration.

### LaunchButton

A self-contained button that opens a launch modal:

```tsx
import { LaunchButton } from '@pumpfunv2/sdk/react';

function App() {
  return (
    <LaunchButton
      apiKey="pk_your_api_key"
      defaultMode="flywheel"
      buttonText="🚀 Launch Token"
      onSuccess={(result) => {
        console.log('Launched:', result.mintAddress);
      }}
      onError={(error) => {
        console.error('Failed:', error.message);
      }}
    />
  );
}
```

### Using the Provider and Hooks

For more control, use the provider and hooks:

```tsx
import { PumpFunV2Provider, useLaunch } from '@pumpfunv2/sdk/react';

function App() {
  return (
    <PumpFunV2Provider config={{ apiKey: 'pk_your_api_key' }}>
      <LaunchForm />
    </PumpFunV2Provider>
  );
}

function LaunchForm() {
  const { launch, isLoading, error, result } = useLaunch({
    onSuccess: (result) => console.log('Success!', result)
  });

  const handleLaunch = async () => {
    await launch({
      name: 'My Token',
      symbol: 'MTK',
      description: 'Created with SDK',
      mode: 'normal',
      creatorWalletPrivateKey: walletKey
    });
  };

  return (
    <button onClick={handleLaunch} disabled={isLoading}>
      {isLoading ? 'Launching...' : 'Launch Token'}
    </button>
  );
}
```

## API Reference

### `PumpFunV2Client`

#### Constructor Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | string | required | Your partner API key |
| `baseUrl` | string | `https://pumpfunv2.fun` | API base URL |
| `timeout` | number | `60000` | Request timeout in ms |
| `retries` | number | `3` | Number of retry attempts |

#### Methods

- `launch(options: LaunchOptions): Promise<LaunchResult>` - Launch a new token
- `getStats(): Promise<PartnerStats>` - Get your launch statistics
- `getTokens(): Promise<LaunchedToken[]>` - List all your launched tokens
- `getLaunchModes(): Promise<LaunchModeInfo[]>` - Get available launch modes
- `validateApiKey(): Promise<boolean>` - Check if your API key is valid

### Error Handling

```typescript
import { PumpFunV2Error } from '@pumpfunv2/sdk';

try {
  await client.launch(options);
} catch (error) {
  if (error instanceof PumpFunV2Error) {
    switch (error.code) {
      case 'UNAUTHORIZED':
        console.log('Invalid API key');
        break;
      case 'RATE_LIMITED':
        console.log('Too many requests, slow down');
        break;
      case 'VALIDATION_ERROR':
        console.log('Invalid launch options:', error.message);
        break;
      default:
        console.log('Error:', error.message);
    }
  }
}
```

## Getting an API Key

1. Visit [pumpfunv2.fun/partner](https://pumpfunv2.fun/partner)
2. Register with your email
3. Copy your API key (shown only once)
4. Start launching tokens!

## Support

- Documentation: [pumpfunv2.fun/api-docs](https://pumpfunv2.fun/api-docs)
- Partner Dashboard: [pumpfunv2.fun/partner](https://pumpfunv2.fun/partner)

## License

MIT