Skip to content

Latest commit

 

History

History
79 lines (63 loc) · 2.03 KB

File metadata and controls

79 lines (63 loc) · 2.03 KB

Sale Program Deployment Guide

Overview

This guide walks you through deploying and initializing your sale program on Solana devnet.

Prerequisites

  • Solana CLI installed and configured
  • Anchor CLI installed
  • A Solana wallet with some SOL (for transaction fees)

Step 1: Build the Program

yarn build
# or
anchor build

Step 2: Deploy to Devnet

yarn deploy:devnet
# or
anchor deploy --provider.cluster devnet

Step 3: Initialize the Program

After deployment, you need to call the initialize function to set up the program state:

yarn init:devnet

This script will:

  • Load your wallet (or generate a test one)
  • Connect to devnet
  • Airdrop SOL if needed (devnet only)
  • Create the program state account
  • Set the authority and USDC mint
  • Verify the initialization

What the Initialize Function Does

The initialize function creates a ProgramState account that stores:

  • Authority: The wallet that can control the program
  • USDC Mint: The USDC token mint address for payments
  • Bump: A seed for PDA derivation

Troubleshooting

Program ID Mismatch

If you see "Account" instead of "Program" on Solscan:

  1. Check that the program ID in lib.rs matches Anchor.toml
  2. Redeploy with the correct ID
  3. Run the initialization script

Insufficient SOL

  • The script will automatically airdrop SOL on devnet
  • Make sure you have enough SOL for transaction fees

Already Initialized

  • The script checks if the program is already initialized
  • If it is, it will show the current state instead of re-initializing

Next Steps

After initialization, you can:

  1. Create sales using create_sale
  2. Buy tokens using buy_tokens
  3. End sales using end_sale

Program Addresses

  • Program ID: 4hWVGsKnY55DpfATfCRFyBFS73CzSaNGUyivhLJNUGvW
  • Program State PDA: Generated from ["program_state"] seed
  • Sale PDAs: Generated from ["sale", creator, sale_id] seeds

Testing

You can test the program locally first:

yarn test

This runs the test suite against a local validator.