# FF Mint Bot - Multi-Threaded Solana Minting CLI

A powerful Node.js CLI tool for parallel Solana minting operations across multiple accounts.

## Features

- ✅ **Parallel Processing**: Run multiple accounts simultaneously with configurable thread limits
- ✅ **Smart Network Detection**: Auto-detects network-specific LUT addresses
- ✅ **Real-time Monitoring**: Live status updates and detailed reporting
- ✅ **Flexible Configuration**: Support for custom RPC endpoints, mint addresses, and URC codes
- ✅ **Account Filtering**: Run specific accounts or all accounts from keyfile
- ✅ **Balance Monitoring**: Prevent failed transactions with automatic balance checks
- ✅ **Export Capabilities**: Export account status to CSV for analysis
- ✅ **Global CLI**: Install once and use anywhere without downloading source code

## Installation

### Global Installation (Recommended)

```bash
# Install globally from npm
npm install -g ff-mint-bot

# Or install from local package
npm install -g .
```

### Development Installation

```bash
npm install
npm run build
npm link  # Create global symlink for development
```

### Publishing to NPM

```bash
# Build the project
npm run build

# Login to npm (first time only)
npm login

# Publish to npm
npm publish

# After publishing, users can install globally:
npm install -g ff-mint-bot
```

## Usage

### Start Minting

```bash
# Basic usage - mint for all accounts
ff-mint-bot mint --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s --urc FF06_URC

# With custom parameters
ff-mint-bot mint \
  --key-pairs ./keypairs/accounts.pri \
  --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s \
  --urc FF06_URC \
  --rpc http://127.0.0.1:8899 \
  --interval 30 \
  --threads 10

# Mint for specific account only
ff-mint-bot mint --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s --urc FF06_URC --account-id 5

# Network-specific examples
ff-mint-bot mint --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s --urc FF06_URC --rpc https://api.mainnet-beta.solana.com
```

### Check Account Status

```bash
# Basic status check
ff-mint-bot status

# With custom RPC and mint address for token balance
ff-mint-bot status --rpc https://api.devnet.solana.com --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s

# Export status to CSV
ff-mint-bot status --export
ff-mint-bot export --mint C8mY9UzzDiLgiGJX789osFVoh4L3CSDqfsPfg6fLdk6s

# Show help
ff-mint-bot --help
ff-mint-bot mint --help
ff-mint-bot status --help
```

## Command Reference

### `mint` Command
Start parallel minting operations for all accounts.

**Required Parameters:**
- `-m, --mint <mint>`: Token mint address
- `-u, --urc <urc>`: URC code

**Optional Parameters:**
- `-k, --key-pairs <file>`: Path to private key file (default: ./keypairs/accounts.pri)
- `-i, --interval <seconds>`: Interval between mints per account (default: 30)
- `-a, --account-id <number>`: Process specific account ID only
- `-r, --rpc <rpc>`: RPC endpoint URL (default: http://127.0.0.1:8899)
- `-l, --lut <address>`: LUT address (auto-detected by network)
- `-t, --threads <number>`: Number of parallel threads (default: 10)

### `status` Command
Display current status of all accounts including balances and activity.

**Parameters:**
- `-k, --key-pairs <file>`: Path to private key file (default: ./keypairs/accounts.pri)
- `-r, --rpc <rpc>`: RPC endpoint URL (default: http://127.0.0.1:8899)
- `-m, --mint <mint>`: Token mint address (for token balance check)
- `--export`: Export status to CSV file

### `export` Command
Export account status to CSV file.

**Parameters:**
- `-k, --key-pairs <file>`: Path to private key file (default: ./keypairs/accounts.pri)
- `-r, --rpc <rpc>`: RPC endpoint URL (default: http://127.0.0.1:8899)
- `-m, --mint <mint>`: Token mint address (for token balance check)

## Network-Specific LUT Addresses

The CLI automatically detects the correct LUT address based on the RPC endpoint:

- **Localnet**: `4L1wqXysMmpNqDqoVXpJexEv24upTp4TUcgoPsDLmsjf`
- **Devnet**: `EebRqpLtUgjX17pJJNNbd6ngtYa34VGa51oYsibwJRXy`
- **Mainnet**: `7DK7pmNkUeeFB3yxt6bJcPCWcG4L3AdCe2WZaBguy9sq`

You can override the LUT address with `--lut` parameter.

## Key File Format

The private key file should be in CSV format with the following columns:

```
public_key,private_key_bs58,private_key_array
FhGn4TJykwL6tKmMkq19dZmV5XAdNcGUVWUA3Edfpf5x,5NyFiYrR2sd1V42kbhP3qK7pzacigfb5wQ7X8YFMA8cmo2mfoA1JwerqZbRxmgsnxAEfC2QQ59cKz9cyx5vkQ8Jr,[219,3,149,34,101,166,169,78,74,164,106,121,190,106,127,65,114,99,4,46,20,22,119,9,108,112,197,237,212,98,2,202,218,84,176,53,136,209,155,186,75,11,48,232,68,117,202,70,195,236,163,46,69,126,7,168,177,71,123,15,10,23,45,239]
```

## Development

```bash
# Start development mode
npm run dev

# Build for production
npm run build

# Run linting
npm run lint

# Format code
npm run format

# Clean build directory
npm run clean
```

## Error Handling

The CLI includes comprehensive error handling:

- **Insufficient SOL**: Automatically skips accounts with < 0.02 SOL
- **RPC Connection Issues**: Provides clear error messages for connection failures
- **Invalid Parameters**: Validates all required parameters before execution
- **Worker Failures**: Gracefully handles worker thread failures

## Monitoring

During minting operations, the CLI provides:

- Real-time status updates every 30 seconds
- Individual account progress tracking
- Transaction hash logging for successful mints
- Error reporting for failed operations
- Automatic retry mechanisms for temporary failures