This guide walks you through deploying and initializing your sale program on Solana devnet.
- Solana CLI installed and configured
- Anchor CLI installed
- A Solana wallet with some SOL (for transaction fees)
yarn build
# or
anchor buildyarn deploy:devnet
# or
anchor deploy --provider.cluster devnetAfter deployment, you need to call the initialize function to set up the program state:
yarn init:devnetThis 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
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
If you see "Account" instead of "Program" on Solscan:
- Check that the program ID in
lib.rsmatchesAnchor.toml - Redeploy with the correct ID
- Run the initialization script
- The script will automatically airdrop SOL on devnet
- Make sure you have enough SOL for transaction fees
- The script checks if the program is already initialized
- If it is, it will show the current state instead of re-initializing
After initialization, you can:
- Create sales using
create_sale - Buy tokens using
buy_tokens - End sales using
end_sale
- Program ID:
4hWVGsKnY55DpfATfCRFyBFS73CzSaNGUyivhLJNUGvW - Program State PDA: Generated from
["program_state"]seed - Sale PDAs: Generated from
["sale", creator, sale_id]seeds
You can test the program locally first:
yarn testThis runs the test suite against a local validator.