#!/bin/bash echo "๐Ÿงช Lottery Devnet Testing Script" echo "==============================" # Set to devnet solana config set --url devnet echo "โœ… Set Solana config to devnet" # Check wallet balance echo "๐Ÿ’ฐ Checking wallet balance..." BALANCE=$(solana balance) echo "Current balance: $BALANCE" # Ensure we have enough SOL (at least 5 SOL for testing) MIN_BALANCE="5.0" BALANCE_NUM=$(echo $BALANCE | cut -d' ' -f1) if (( $(echo "$BALANCE_NUM < $MIN_BALANCE" | bc -l) )); then echo "โŒ Insufficient balance for testing. Need at least 5 SOL." echo "๐Ÿ’ธ Requesting airdrop..." solana airdrop 5 echo "โณ Waiting 10 seconds for airdrop confirmation..." sleep 10 fi # Build the program echo "๐Ÿ”จ Building Anchor program..." anchor build if [ $? -ne 0 ]; then echo "โŒ Build failed!" exit 1 fi # Deploy the program echo "๐Ÿš€ Deploying to devnet..." anchor deploy --provider.cluster devnet if [ $? -ne 0 ]; then echo "โŒ Deploy failed!" exit 1 fi # Generate the IDL echo "๐Ÿ“ Generating IDL..." anchor idl init -f target/idl/lottery_simple.json $(solana-keygen pubkey target/deploy/lottery_simple-keypair.json) echo "โœ… Program deployed successfully!" # Show deployment info PROGRAM_ID=$(solana-keygen pubkey target/deploy/lottery_simple-keypair.json) echo "๐Ÿ“ Program ID: $PROGRAM_ID" # Create a simple test to verify the deployment echo "๐Ÿงช Creating simple test..." # Generate a new keypair for the mint echo "๐Ÿ”‘ Creating mint keypair..." solana-keygen new --outfile mint-keypair.json --no-bip39-passphrase # Create the mint echo "๐Ÿช™ Creating token mint..." MINT_ADDRESS=$(solana-keygen pubkey mint-keypair.json) spl-token create-token mint-keypair.json echo "โœ… Token mint created: $MINT_ADDRESS" # Generate devnet config echo "๐Ÿ“„ Generating devnet configuration..." cat > devnet-config.json << EOF { "programId": "$PROGRAM_ID", "mintAddress": "$MINT_ADDRESS", "devWallet": "$(solana address)", "cluster": "devnet", "rpcUrl": "https://api.devnet.solana.com" } EOF echo "โœ… Devnet configuration saved to devnet-config.json" echo "" echo "๐ŸŽ‰ Deployment complete!" echo "๐Ÿ“‹ Next steps:" echo " 1. Update your frontend to use devnet-config.json" echo " 2. Initialize the program state using the frontend or CLI" echo " 3. Test buy/sell functionality" echo "" echo "โš ๏ธ Remember: This is devnet SOL - not real money!"