You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB

#!/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!"