npm package: @suilab/token-creator-sdk
Description: TypeScript SDK for creating native SUI tokens using SUILab's API
Author: SUI Lab Team
Latest version: 1.0.0

# @suilab/token-creator-sdk

TypeScript SDK for creating native SUI tokens using SUILab's API. Simplifies token creation for developers building on the SUI blockchain.

## Installation

```bash
npm install @suilab/token-creator-sdk
```

## Quick Start

```typescript
import { SuiLabTokenCreatorSDK } from '@suilab/token-creator-sdk';

// Initialize SDK with your API key
const sdk = new SuiLabTokenCreatorSDK('SUILab_YOUR_API_KEY', {
  developerWallet: '0xYOUR_WALLET_ADDRESS',
  developerFee: 3, // 3 SUI fee you charge users
  network: 'mainnet'
});

// Create a token
const result = await sdk.createNativeToken({
  name: 'My Token',
  symbol: 'MTK',
  decimals: 9,
  totalSupply: 1000000,
  description: 'My awesome token on SUI',
  userAddress: userWalletAddress,
  icon: 'https://example.com/icon.png' // optional
});

console.log('Token created:', result.tokenId);
console.log('Transaction:', result.digest);
```

## Features

- ✅ Simple token creation in 3 lines of code
- ✅ Automatic fee calculation and handling
- ✅ Built-in parameter validation
- ✅ IPFS icon upload support
- ✅ Full TypeScript support with types
- ✅ Error handling and retry logic

## API Reference

### `SuiLabTokenCreatorSDK`

Main SDK class for token creation.

#### Constructor

```typescript
constructor(apiKey: string, config: TokenCreatorConfig)
```

**Parameters:**
- `apiKey` - Your SUILab API key (get from https://docs.suilab.fun/apikey)
- `config` - SDK configuration object

**Example:**
```typescript
const sdk = new SuiLabTokenCreatorSDK('SUILab_abc123', {
  developerWallet: '0x742d...',
  developerFee: 5,
  network: 'mainnet'
});
```

#### Methods

##### `createNativeToken(params)`

Creates a native SUI token.

**Parameters:**
```typescript
interface TokenCreationParams {
  name: string;           // Token name
  symbol: string;         // Token symbol (uppercase)
  decimals: number;       // Decimals (0-18)
  totalSupply: number;    // Total supply
  description: string;    // Token description
  userAddress: string;    // User's wallet address
  icon?: string | File;   // Optional icon URL or File
  metadata?: object;      // Optional metadata
}
```

**Returns:** `Promise<TokenCreationResult>`

**Example:**
```typescript
const token = await sdk.createNativeToken({
  name: 'My DAO Token',
  symbol: 'DAO',
  decimals: 9,
  totalSupply: 10_000_000,
  description: 'Governance token for My DAO',
  userAddress: '0x742d...'
});
```

##### `estimateFees()`

Get fee breakdown for token creation.

**Returns:** `FeeEstimate`

**Example:**
```typescript
const fees = sdk.estimateFees();
console.log(fees);
// {
//   platformFee: 2,      // SUILab platform fee
//   developerFee: 3,     // Your custom fee
//   networkFee: 0.05,    // Estimated network fee
//   total: 5.05          // Total
// }
```

##### `validateParams(params)`

Validate token parameters before creation.

**Returns:** `ValidationResult`

**Example:**
```typescript
const validation = sdk.validateParams(myParams);
if (!validation.isValid) {
  console.error('Errors:', validation.errors);
}
```

## Fee Structure

When users create tokens through your integration:

| Fee Type | Amount | Recipient |
|----------|--------|-----------|
| Platform Fee | 2 SUI | SUILab (mandatory) |
| Developer Fee | Customizable | You (set in config) |
| Network Fee | ~0.05 SUI | SUI Validators |

**Example:** If you set `developerFee: 3`, users pay **5.05 SUI total** (2 + 3 + 0.05)

## Configuration

### TokenCreatorConfig

```typescript
interface TokenCreatorConfig {
  developerWallet: string;   // Your wallet to receive fees
  developerFee: number;      // Fee you charge (in SUI)
  network?: 'mainnet' | 'testnet';  // Default: 'mainnet'
  apiEndpoint?: string;       // Custom API endpoint (optional)
}
```

## Error Handling

```typescript
try {
  const result = await sdk.createNativeToken(params);
  console.log('Success!', result);
} catch (error) {
  console.error('Failed:', error.message);
}
```

Common errors:
- `Invalid API key format` - Check your API key
- `Validation failed` - Check token parameters
- `API Error` - Check API status or network
- `No response from API` - Network issue

## Utilities

### IPFS Upload

```typescript
import { uploadToIPFS } from '@suilab/token-creator-sdk';

const iconUrl = await uploadToIPFS(
  imageFile,
  'YOUR_PINATA_API_KEY',
  'YOUR_PINATA_SECRET'
);
```

### Unit Conversion

```typescript
import { suiToMist, mistToSui } from '@suilab/token-creator-sdk';

const mist = suiToMist(5);      // 5 SUI → 5000000000 MIST
const sui = mistToSui(BigInt(5000000000));  // → 5 SUI
```

## Get API Key

1. Visit https://docs.suilab.fun/apikey/requestapikey
2. Fill out the request form
3. Receive your API key via email (24-48 hours)

## Support

- Documentation: https://docs.suilab.fun/apikey
- Email: support@suilab.fun
- GitHub: https://github.com/suilab/token-creator-sdk

## License

MIT

---

**Built with ❤️ by SUI Lab Team**