Complete guide for building and deploying the Solana smart contracts and Rust backend.
- devnet deployment https://solscan.io/account/9bca4kbDn7uyQWQaqfKpe8hCdbBh6KqJFNbkzwHhieC3?cluster=devnet
- Rust: 1.70+ (Install)
- Solana CLI: 1.17+ (Install)
- Anchor Framework: 0.29+ (Install)
- Node.js: 18+ (Install)
- PostgreSQL: 14+ (Install)
- Redis: 7+ (Install)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/envsh -c "$(curl -sSfL https://release.solana.com/v1.17.0/install)"
export PATH="/home/$USER/.local/share/solana/install/active_release/bin:$PATH"cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
avm install latest
avm use latestgit clone git@github.com:degenSumi/perps-position-management.git
cd perps-position-managementcd position-management-systemsolana config set --url https://api.devnet.solana.comsolana config set --url https://api.mainnet-beta.solana.comsolana-keygen new --outfile ~/.config/solana/deployer.jsonsolana airdrop 2anchor buildThis generates:
- Program binary:
target/deploy/position_management_system.so - IDL:
target/idl/position_management_system.json
anchor keys listCopy the program ID and update it in:
Anchor.tomlprograms/position_management_system/src/lib.rs(atdeclare_id!)
anchor buildanchor deploysolana program show anchor testcd backendCreate .env file:
Or use the dev env
# Solana Configuration
SOLANA_RPC_URL=https://api.devnet.solana.com
PROGRAM_ID=9bca4kbDn7uyQWQaqfKpe8hCdbBh6KqJFNbkzwHhieC3
SOLANA_PRIVATE_KEY=<BASE58_PRIVATE_KEY> # imp used for all the transactions
# Redis Configuration
REDIS_URL=redis://localhost:6379
# Server Configuration
PORT=3000
# Monitoring
RUST_LOG=infocargo buildcargo runcargo build --release- Smart contracts deployed and verified
- Backend running and accessible
- Database initialized with schema
- Redis connected
- WebSocket connections working
- Health check endpoint responds
- Position opening/closing tested
- Liquidation alerts working
- Logs properly configured
- Check SOL balance:
solana balance - Verify RPC URL:
solana config get - Check program size:
ls -lh target/deploy/*.so
- Check
.envconfiguration - Check Redis connectivity
- Review logs for errors
- Check firewall rules
- Verify port 3000 is open
- Test with Postman or wscat
End of Deployment Guide
