This document describes the enhanced network configuration management system implemented for Uzima-Contracts, providing robust, safe, and flexible network handling for Soroban smart contract deployment.
The network configuration management system addresses the issue of manual network configuration being prone to errors across environments. It provides:
- Environment-specific configurations with validation checks
- Auto-detection of available networks
- Fallback mechanisms for network unavailability
- Safety features including mainnet confirmation prompts, transaction simulation, and dry-run mode
- Network verification and connectivity testing
-
Network Configuration File (
config/networks.toml)- Centralized network definitions
- Environment-specific settings
- Safety configurations
-
Network Manager Script (
scripts/network_manager.sh)- Network validation and configuration
- Auto-detection and fallback
- Safety checks
-
Enhanced Deployment Script (
scripts/deploy_enhanced.sh)- Safe deployment with network management
- Simulation and dry-run modes
- Comprehensive error handling
-
Validation Script (
scripts/validate_network_config.sh)- Configuration validation
- Connectivity testing
- Deployment readiness checks
The system supports four primary networks:
| Network | Environment | RPC URL | Safety Level | Funding Required |
|---|---|---|---|---|
local |
Development | http://localhost:8000/soroban/rpc |
Low | No |
testnet |
Testing | https://soroban-testnet.stellar.org |
Medium | Yes |
futurenet |
Testing | https://rpc-futurenet.stellar.org |
Medium | Yes |
mainnet |
Production | https://soroban-mainnet.stellar.org |
High | No |
[networks.<network_name>]
name = "Human-readable name"
description = "Network description"
rpc-url = "RPC endpoint URL"
network-passphrase = "Stellar network passphrase"
horizon-url = "Horizon server URL"
friendbot-url = "Faucet URL (if available)"
environment = "development|testing|production"
requires-funding = true|false
gas-configuration = { max-instructions = 100_000_000, tx-resource-fee = 100 }
safety-level = "low|medium|high"
confirmation-required = true|falseNetworks are organized into groups for easier management:
- Development:
local - Testing:
testnet,futurenet - Production:
mainnet
# Configure a specific network
./scripts/network_manager.sh configure testnet
# Configure all networks
./scripts/network_manager.sh configure-all
# Force reconfiguration
FORCE=true ./scripts/network_manager.sh configure testnet# Show all network status
./scripts/network_manager.sh status
# Show specific network status
./scripts/network_manager.sh status testnet# Validate specific network
./scripts/network_manager.sh validate testnet
# Auto-detect available networks
./scripts/network_manager.sh detect# Deploy to testnet
./scripts/deploy_enhanced.sh medical_records testnet
# Deploy with custom identity
./scripts/deploy_enhanced.sh medical_records testnet --identity alice# Dry-run mode (no actual deployment)
./scripts/deploy_enhanced.sh medical_records mainnet --dry-run
# Simulation mode (test transaction without execution)
./scripts/deploy_enhanced.sh medical_records mainnet --simulation
# Auto-fallback if network unavailable
./scripts/deploy_enhanced.sh medical_records testnet --auto-fallback# Skip building (use existing WASM)
./scripts/deploy_enhanced.sh medical_records testnet --skip-build
# Force deployment (bypass some checks)
./scripts/deploy_enhanced.sh medical_records mainnet --force
# Debug mode with verbose output
./scripts/deploy_enhanced.sh medical_records testnet --debug# Validate all configurations
./scripts/validate_network_config.sh
# Validate specific network
./scripts/validate_network_config.sh --network testnet
# Validate deployment prerequisites
./scripts/validate_network_config.sh --contract medical_records --network testnetThe system includes multiple layers of protection for mainnet operations:
- Confirmation Required: Mainnet deployments require explicit confirmation
- Dry-run Mode: Test deployments without executing transactions
- Simulation Mode: Simulate transactions to check for errors
- Safety Checks: Validate configurations before deployment
# Safe mainnet deployment with all safety features
./scripts/deploy_enhanced.sh medical_records mainnet --dry-run --simulation
# After validation, proceed with actual deployment
./scripts/deploy_enhanced.sh medical_records mainnet
# Type 'CONFIRM' when prompted to proceedThe system automatically detects the current environment:
- CI Environment: Detected via
CI=trueenvironment variable - Production: Detected via
NODE_ENV=productionin.envfile - Testing: Detected via
NODE_ENV=testin.envfile - Development: Default environment
# Automatically detect available networks
./scripts/network_manager.sh detectThe system tests connectivity to each network and reports available options.
# Use fallback if preferred network unavailable
./scripts/deploy_enhanced.sh medical_records testnet --auto-fallbackFallback order:
- Try the requested network
- Fall back to
localif available - Fall back to
testnetif available - Fail if no networks are available
The system performs comprehensive validation:
- File Validation: Check if configuration files exist and are readable
- Syntax Validation: Validate TOML syntax
- Network Completeness: Ensure all required fields are present
- Connectivity Testing: Test network connectivity
- Soroban Configuration: Verify Soroban CLI configuration
- Identity Validation: Check identity configuration
- Deployment Prerequisites: Validate contract build requirements
========================================
VALIDATION REPORT
========================================
Total Tests: 15
Passed: 15
Failed: 0
Success Rate: 100%
馃帀 All tests passed!
SOROBAN_RPC_URL: Override RPC URL for current networkSOROBAN_NETWORK_PASSPHRASE: Override network passphraseDEBUG: Enable debug output (true/false)DRY_RUN: Enable dry-run mode (true/false)SIMULATION: Enable simulation mode (true/false)FORCE: Force operations (true/false)
# Enable debug output
DEBUG=true ./scripts/deploy_enhanced.sh medical_records testnet
# Dry-run mode
DRY_RUN=true ./scripts/deploy_enhanced.sh medical_records mainnet
# Override RPC URL
SOROBAN_RPC_URL=http://localhost:8001 ./scripts/deploy_enhanced.sh medical_records local# Check network status
./scripts/network_manager.sh status
# Test connectivity
./scripts/network_manager.sh validate testnet
# Try fallback
./scripts/deploy_enhanced.sh medical_records testnet --auto-fallback# Validate configuration
./scripts/validate_network_config.sh
# Check TOML syntax
python3 -c "import tomllib; print(tomllib.load(open('config/networks.toml', 'rb')))"# Check identity status
soroban config identity show
# Generate new identity
soroban config identity generate my-identity# Check contract build
cargo check -p medical_records --target wasm32-unknown-unknown
# Clean and rebuild
cargo clean -p medical_records
cargo build -p medical_records --target wasm32-unknown-unknown --releaseEnable debug mode for detailed output:
DEBUG=true ./scripts/deploy_enhanced.sh medical_records testnet --debug- name: Validate Network Configuration
run: ./scripts/validate_network_config.sh --network testnet
- name: Deploy to Testnet
run: ./scripts/deploy_enhanced.sh medical_records testnet --auto-fallback
env:
DRY_RUN: false
SIMULATION: true# Development
./scripts/deploy_enhanced.sh medical_records local
# Testing
./scripts/deploy_enhanced.sh medical_records testnet --simulation
# Production (with safety checks)
./scripts/deploy_enhanced.sh medical_records mainnet --dry-run- Always Use Enhanced Scripts: Use
deploy_enhanced.shinstead of manual deployment - Test Before Production: Always use simulation mode before mainnet deployment
- Validate Configurations: Run validation scripts before deployment
- Use Auto-Fallback: Enable auto-fallback for better reliability
- Monitor Network Status: Check network status before critical deployments
- Keep Configurations Updated: Regularly update network configurations
- Use Environment Variables: Leverage environment variables for CI/CD integration
# Manual network configuration
soroban config network add testnet \
--rpc-url https://soroban-testnet.stellar.org \
--network-passphrase "Test SDF Network ; September 2015"
# Manual deployment
soroban contract deploy --wasm contract.wasm --source alice --network testnet# Automatic network configuration and deployment
./scripts/deploy_enhanced.sh medical_records testnet --identity alice- Reduced Errors: Automated configuration eliminates manual errors
- Better Safety: Built-in safety checks prevent accidental mainnet deployments
- Improved Reliability: Auto-detection and fallback mechanisms
- Enhanced Debugging: Comprehensive logging and error reporting
- CI/CD Integration: Better support for automated deployments
When contributing to the network configuration system:
- Test All Networks: Ensure changes work with all supported networks
- Validate Configurations: Run validation scripts after changes
- Update Documentation: Keep documentation up to date
- Test Safety Features: Verify safety features work correctly
- Check Backward Compatibility: Ensure existing workflows continue to work
For issues or questions about the network configuration system:
- Check the validation report for configuration issues
- Review debug output for detailed error information
- Consult the troubleshooting section
- Check GitHub issues for known problems
- Create new issues with detailed error reports and configuration details