Skip to content

Commit 3cf5f64

Browse files
Copilot0xrinegade
andcommitted
Fix build configuration and prepare proper devnet deployment infrastructure
Co-authored-by: 0xrinegade <[email protected]>
1 parent 90509bc commit 3cf5f64

File tree

111 files changed

+7635
-1974
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+7635
-1974
lines changed

Anchor.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ seeds = false
66
skip-lint = false
77

88
[programs.localnet]
9-
p2p_exchange = "FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9"
9+
p2p_exchange = "4eLxPSpK6Qi1AyNx79Ns4DoVqodp85sEphzPtFqLKTRk"
10+
11+
[programs.devnet]
12+
p2p_exchange = "4eLxPSpK6Qi1AyNx79Ns4DoVqodp85sEphzPtFqLKTRk"
1013

1114
[registry]
1215
url = "https://api.apr.dev"
1316

1417
[provider]
15-
cluster = "Localnet"
18+
cluster = "devnet"
1619
wallet = "~/.config/solana/id.json"
1720

1821
[scripts]

anchor.tar.gz

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Not Found

deploy-to-devnet.sh

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
3+
# P2P Exchange Program Deployment Script for Solana Devnet
4+
# This script builds and deploys the Anchor program to Solana devnet
5+
6+
set -e
7+
8+
echo "🚀 Starting P2P Exchange Program Deployment to Devnet"
9+
echo "=================================================="
10+
11+
# Colors for output
12+
RED='\033[0;31m'
13+
GREEN='\033[0;32m'
14+
YELLOW='\033[1;33m'
15+
NC='\033[0m' # No Color
16+
17+
# Check if required tools are installed
18+
echo "📋 Checking prerequisites..."
19+
20+
if ! command -v solana &> /dev/null; then
21+
echo -e "${RED}❌ Solana CLI is not installed${NC}"
22+
echo "Please install from: https://docs.solana.com/cli/install-solana-cli-tools"
23+
exit 1
24+
fi
25+
26+
if ! command -v anchor &> /dev/null; then
27+
echo -e "${RED}❌ Anchor CLI is not installed${NC}"
28+
echo "Please install from: https://anchor-lang.com/docs/installation"
29+
exit 1
30+
fi
31+
32+
echo -e "${GREEN}✅ Prerequisites met${NC}"
33+
34+
# Configuration
35+
PROGRAM_ID="4eLxPSpK6Qi1AyNx79Ns4DoVqodp85sEphzPtFqLKTRk"
36+
NETWORK="devnet"
37+
KEYPAIR_PATH="./program-keypair.json"
38+
39+
echo "📊 Deployment Configuration:"
40+
echo " Program ID: $PROGRAM_ID"
41+
echo " Network: $NETWORK"
42+
echo " Keypair: $KEYPAIR_PATH"
43+
44+
# Set Solana CLI to devnet
45+
echo "🌐 Configuring Solana CLI for devnet..."
46+
solana config set --url https://api.devnet.solana.com
47+
solana config set --keypair ~/.config/solana/id.json
48+
49+
# Check wallet balance
50+
echo "💰 Checking wallet balance..."
51+
BALANCE=$(solana balance --lamports)
52+
MIN_BALANCE=1000000000 # 1 SOL in lamports
53+
54+
if [ "$BALANCE" -lt "$MIN_BALANCE" ]; then
55+
echo -e "${YELLOW}⚠️ Low balance detected. Requesting devnet SOL...${NC}"
56+
solana airdrop 2
57+
echo "Waiting for airdrop confirmation..."
58+
sleep 5
59+
fi
60+
61+
echo "Current balance: $(solana balance) SOL"
62+
63+
# Ensure program keypair exists
64+
if [ ! -f "$KEYPAIR_PATH" ]; then
65+
echo -e "${YELLOW}⚠️ Program keypair not found. Generating new one...${NC}"
66+
solana-keygen new --no-bip39-passphrase --force --outfile "$KEYPAIR_PATH"
67+
fi
68+
69+
ACTUAL_PROGRAM_ID=$(solana-keygen pubkey "$KEYPAIR_PATH")
70+
if [ "$ACTUAL_PROGRAM_ID" != "$PROGRAM_ID" ]; then
71+
echo -e "${RED}❌ Program keypair mismatch!${NC}"
72+
echo "Expected: $PROGRAM_ID"
73+
echo "Actual: $ACTUAL_PROGRAM_ID"
74+
echo "Either use the correct keypair or update the program ID in the code."
75+
exit 1
76+
fi
77+
78+
echo -e "${GREEN}✅ Program keypair validated${NC}"
79+
80+
# Build the program
81+
echo "🔨 Building Anchor program..."
82+
anchor build
83+
84+
if [ $? -ne 0 ]; then
85+
echo -e "${RED}❌ Build failed${NC}"
86+
exit 1
87+
fi
88+
89+
echo -e "${GREEN}✅ Build successful${NC}"
90+
91+
# Deploy the program
92+
echo "🚀 Deploying program to devnet..."
93+
echo "This may take a few minutes..."
94+
95+
solana program deploy \
96+
--keypair "$KEYPAIR_PATH" \
97+
--url https://api.devnet.solana.com \
98+
./target/deploy/p2p_exchange.so
99+
100+
if [ $? -ne 0 ]; then
101+
echo -e "${RED}❌ Deployment failed${NC}"
102+
exit 1
103+
fi
104+
105+
echo -e "${GREEN}✅ Program deployed successfully!${NC}"
106+
107+
# Verify deployment
108+
echo "🔍 Verifying deployment..."
109+
solana program show "$PROGRAM_ID" --url https://api.devnet.solana.com
110+
111+
if [ $? -eq 0 ]; then
112+
echo -e "${GREEN}✅ Deployment verified${NC}"
113+
else
114+
echo -e "${YELLOW}⚠️ Could not verify deployment (this is sometimes normal)${NC}"
115+
fi
116+
117+
# Create IDL account (optional but recommended)
118+
echo "📄 Initializing IDL account..."
119+
anchor idl init "$PROGRAM_ID" \
120+
--filepath ./target/idl/p2p_exchange.json \
121+
--provider.cluster devnet
122+
123+
echo ""
124+
echo "🎉 Deployment Complete!"
125+
echo "=============================="
126+
echo "Program ID: $PROGRAM_ID"
127+
echo "Network: Solana Devnet"
128+
echo "Explorer: https://explorer.solana.com/address/$PROGRAM_ID?cluster=devnet"
129+
echo ""
130+
echo "📋 Next Steps:"
131+
echo "1. Update your frontend configuration with this Program ID"
132+
echo "2. Test program functions using the frontend"
133+
echo "3. Monitor transactions on Solana Explorer"
134+
echo ""
135+
echo "🔗 Useful Commands:"
136+
echo " View program info: solana program show $PROGRAM_ID --url https://api.devnet.solana.com"
137+
echo " View IDL: anchor idl fetch $PROGRAM_ID --provider.cluster devnet"
138+
echo " Program logs: solana logs $PROGRAM_ID --url https://api.devnet.solana.com"

idl_output.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Error: EOF while parsing a value at line 1 column 0

0 commit comments

Comments
 (0)