# Solana Playground Deployment Guide

## Step-by-Step Deployment Instructions

### 1. Prepare Your Contract

1. **Copy the Contract Code**:
   ```rust
   // Copy the entire content from Contract/SolanaICO.rs
   // Make sure to replace the declare_id!() with your own program ID
   ```

2. **Generate Program ID**:
   - Go to [Solana Playground](https://playground.solana.com/)
   - Click "Create New Project"
   - Copy the generated program ID
   - Replace `declare_id!("11111111111111111111111111111111");` with your program ID

### 2. Deploy on Solana Playground

1. **Create New Project**:
   - Visit [Solana Playground](https://playground.solana.com/)
   - Click "Create New Project"
   - Choose "Anchor" as the framework

2. **Paste Contract Code**:
   - Replace the default code with your `SolanaICO.rs` content
   - Update the `declare_id!()` with your program ID

3. **Build the Program**:
   - Click "Build" button
   - Wait for successful compilation
   - Check for any errors and fix them

4. **Deploy to Devnet**:
   - Click "Deploy" button
   - Choose "Devnet" for testing
   - Wait for deployment to complete
   - Copy your program ID for frontend configuration

### 3. Test Your Deployment

1. **Create Test Token**:
   ```bash
   # Using Solana CLI
   spl-token create-token --decimals 9
   ```

2. **Initialize Presale**:
   - Use the frontend to initialize a presale
   - Enter your token mint address
   - Set presale parameters

3. **Test Token Purchase**:
   - Connect a different wallet
   - Try buying tokens
   - Verify token transfer

### 4. Update Frontend

1. **Update Program ID**:
   ```javascript
   // In pages/index.js
   const PROGRAM_ID = new PublicKey("YOUR_DEPLOYED_PROGRAM_ID");
   ```

2. **Test Frontend**:
   ```bash
   npm run dev
   ```

### 5. Mainnet Deployment

1. **Switch to Mainnet**:
   - In Solana Playground, change network to "Mainnet"
   - Deploy the same contract
   - Update frontend with mainnet program ID

2. **Update RPC Endpoint**:
   ```javascript
   // Use mainnet RPC
   const endpoint = "https://solana-mainnet.api.syndica.io/api-key/4J4fH9ePWjSJUFMVaY3wqwhJmiEfDcnREv61xMXsCM77urfGT5cBpNMmgq5dVMbBmriust1U2wNmGkM2EbHGqsSW1GKiV14KQnL";
   ```

## Important Notes

- **Always test on devnet first**
- **Keep your program ID safe**
- **Ensure sufficient SOL for deployment**
- **Verify all transactions on Solana Explorer**

## Troubleshooting

### Common Issues

1. **Build Errors**:
   - Check Rust syntax
   - Verify all imports are correct
   - Ensure program ID is valid

2. **Deployment Failures**:
   - Check SOL balance
   - Verify network connection
   - Try different RPC endpoint

3. **Frontend Issues**:
   - Verify program ID is correct
   - Check wallet connection
   - Ensure proper network configuration

### Support Resources

- [Solana Playground Documentation](https://docs.solana.com/developing/playground)
- [Anchor Framework Docs](https://www.anchor-lang.com/)
- [Solana Discord](https://discord.gg/solana)
