Location: contracts/runtime-guard-wrapper/
A complete Soroban smart contract that wraps target contracts with runtime validation:
Features Implemented:
- ✅ Guard configuration management
- ✅ Pre/post-execution validation
- ✅ Storage integrity checking
- ✅ Execution metrics collection
- ✅ Event emission for monitoring
- ✅ Health check functionality
- ✅ Statistics retrieval (
get_stats) - ✅ Deployment manifest support
Key Functions:
init(env, wrapped_contract) // Initialize wrapper
execute_guarded(env, fn_name, args) // Execute with guards
health_check(env) -> bool // Validate wrapper state
get_stats(env) -> (u32, u32, u32) // Get validation statisticsLocation: tooling/sanctifier-cli/src/commands/deploy.rs
Integrated into Sanctifier CLI for one-command deployments:
Features:
- ✅ Contract path validation
- ✅ Environment variable retrieval
- ✅ Automatic building with cargo
- ✅ WASM file discovery
- ✅ Testnet deployment via soroban CLI
- ✅ Post-deployment validation
- ✅ JSON/text output formats
- ✅ Error handling with retries
Usage:
sanctifier deploy <PATH> \
--network testnet \
--secret-key <KEY> \
--validate \
--output-format jsonLocation: scripts/deploy-soroban-testnet.sh
Production-ready automation script with comprehensive features:
Features Implemented:
- ✅ Complete environment validation
- ✅ Multi-contract support
- ✅ Automatic WASM building
- ✅ Intelligent WASM file discovery
- ✅ Deployment with retry logic (max 3 attempts)
- ✅ Continuous validation loop
- ✅ Deployment manifest tracking
- ✅ JSON manifest generation
- ✅ Comprehensive logging
- ✅ Dry-run mode
- ✅ Debug logging support
- ✅ Colored output
- ✅ Circular buffer for unbounded data
Execution Flow:
- Environment validation
- Contract building
- WASM file discovery
- Deployment with retries
- Post-deployment validation
- Optional continuous validation loop
- Manifest/log generation
Configuration Options:
--network <testnet|futurenet|mainnet>
--no-validate # Skip post-deployment validation
--no-continuous # Disable continuous validation
--dry-run # No actual deployment
--interval <seconds> # Validation interval
--debug # Enable debug loggingLocation: .github/workflows/soroban-deploy.yml
Complete CI/CD pipeline for automated deployment:
Jobs Implemented:
-
build-and-deploy (Main deployment)
- Checkout code
- Install Rust + WASM target
- Cache dependencies
- Format/lint checks
- Build WASM artifacts
- Deploy to testnet
- Upload artifacts
-
continuous-validation (Post-deployment checks)
- Run health checks
- Collect statistics
- Validate contract state
-
notification (Status reporting)
- Generate deployment summary
- Create GitHub checks
- Post to job summary
Triggers:
- ✅ Push to main (on contract/script changes)
- ✅ Scheduled: Every 6 hours (continuous validation)
- ✅ Manual dispatch: With network selection & dry-run option
Artifacts:
- ✅ deployment-manifest-<RUN_ID>
- ✅ deployment-log-<RUN_ID>
- ✅ Retained for 30 days
Location: contracts/runtime-guard-wrapper/tests/integration_tests.rs
Comprehensive test suite covering:
- ✅ Wrapper initialization
- ✅ Pre/post-execution guards
- ✅ Storage integrity validation
- ✅ Execution logging
- ✅ Metrics collection
- ✅ Health checks
- ✅ Event emission
- ✅ Statistics retrieval
Test Coverage:
- Unit tests for core functionality
- Integration tests for full workflows
- Guard behavior validation
- Storage limit testing
Files Created:
- ✅
.env.example- Template with all configuration options - ✅
docs/ci-cd-setup.md- Complete CI/CD setup guide - ✅
docs/soroban-deployment.md- Full deployment documentation - ✅
QUICK_START.md- 5-minute quick start guide - ✅
SOROBAN_DEPLOYMENT.md- Main deployment automation guide
Configuration Features:
- ✅ Environment variable templates
- ✅ GitHub Secrets documentation
- ✅ Local development setup
- ✅ CI/CD configuration guide
- ✅ Security best practices
- ✅ Troubleshooting guide
User/CI
↓
┌─────────────────────────────────────┐
│ sanctifier deploy (CLI) │
│ OR │
│ ./deploy-soroban-testnet.sh (Bash) │
│ OR │
│ GitHub Actions Workflow │
└────────────────────┬────────────────┘
↓
┌───────────────────────┐
│ Build Contract │
│ (cargo/wasm32) │
└───────────┬───────────┘
↓
┌───────────────────────┐
│ Deploy to Testnet │
│ (soroban CLI) │
└───────────┬───────────┘
↓
┌───────────────────────┐
│ Validate Deployment │
│ (health_check) │
└───────────┬───────────┘
↓
┌────────────────────────────────┐
│ Optional: Continuous │
│ Validation Loop │
│ (Every N seconds) │
└────────────────────────────────┘
Secrets Management:
- ✅ GitHub Secrets integration
- ✅ Environment variable isolation
- ✅ .env.local exclusion (gitignore)
- ✅ Secure credential documentation
Best Practices Enforced:
- ✅ No hardcoded secrets
- ✅ Credential rotation guidance
- ✅ Separate keys per network
- ✅ Branch protection support
- ✅ Audit trail logging
Optimizations:
- ✅ Circular buffers for unbounded data
- ✅ Retries with exponential backoff
- ✅ Caching of dependencies
- ✅ Parallel artifact uploads
- ✅ Incremental compilation support
Resource Management:
- Call log: Last 100 entries
- Execution metrics: Last 1000 entries
- Guard failures: Tracked but bounded
- Deployment manifest: Cumulative
- QUICK_START.md - 5-minute setup
- SOROBAN_DEPLOYMENT.md - Complete deployment guide
- docs/ci-cd-setup.md - CI/CD configuration
- docs/soroban-deployment.md - Detailed deployment docs
- contracts/runtime-guard-wrapper/README.md - Contract details
- tooling/sanctifier-cli/README.md - CLI documentation
- .github/workflows/soroban-deploy.yml - Workflow inline docs
- .env.example - Full configuration template
- Inline comments - Throughout all scripts
source .env.local
./scripts/deploy-soroban-testnet.sh --network testnetsanctifier deploy contracts/runtime-guard-wrapper \
--network testnet \
--validategh secret set SOROBAN_SECRET_KEY --body "SBXXXXXXX..."
# Automatically triggers on push or manual dispatch./scripts/deploy-soroban-testnet.sh --dry-run --debug- Full Automation: Complete deployment pipeline from CLI or GitHub Actions
- Continuous Validation: Automatic periodic health checks
- Comprehensive Monitoring: Deployment manifests and detailed logging
- Production-Ready: Error handling, retries, security best practices
- Easy Integration: Works with existing Sanctifier CLI
- Extensible: Supports multiple contracts and configurations
- Well-Documented: Guides for setup, usage, and troubleshooting
source .env.local
./scripts/deploy-soroban-testnet.sh --network testnet
# Deploys and validates, runs continuous validationgh secret set SOROBAN_SECRET_KEY --body "SBXXXXXXX..."
# Push to main → Automatic deployment → Continuous validation./scripts/deploy-soroban-testnet.sh --dry-run --debug --network testnet
# Simulates deployment without making changes./scripts/deploy-soroban-testnet.sh \
--network testnet \
--interval 600 \
--no-continuous
# Deploy with 10-minute validation interval, no continuous loopcontracts/runtime-guard-wrapper/Cargo.tomlcontracts/runtime-guard-wrapper/src/lib.rscontracts/runtime-guard-wrapper/tests/integration_tests.rscontracts/runtime-guard-wrapper/README.mdtooling/sanctifier-cli/src/commands/deploy.rsscripts/deploy-soroban-testnet.sh.github/workflows/soroban-deploy.ymlQUICK_START.mdSOROBAN_DEPLOYMENT.mddocs/ci-cd-setup.md.env.example(updated)
Cargo.toml(added runtime-guard-wrapper)tooling/sanctifier-cli/src/commands/mod.rstooling/sanctifier-cli/src/main.rsREADME.md(added deployment info)
-
Configure Environment
cp .env.example .env.local # Edit with SOROBAN_SECRET_KEY -
Test Deployment
./scripts/deploy-soroban-testnet.sh --dry-run
-
Deploy to Testnet
source .env.local ./scripts/deploy-soroban-testnet.sh --network testnet -
Set Up CI/CD (Optional)
gh secret set SOROBAN_SECRET_KEY --body "YOUR_KEY" # Subsequent pushes trigger automated deployment
-
Monitor Validation
tail -f .deployment.log cat .deployment-manifest.json | jq '.'
This implementation provides end-to-end automation for deploying runtime guard wrapper contracts to Soroban testnet with:
✅ Multiple Entry Points: CLI, Bash script, GitHub Actions
✅ Continuous Validation: Automatic health checks and metrics
✅ Production Ready: Error handling, retries, logging
✅ Well Documented: Quick start guide + detailed guides
✅ Secure by Default: Environment variables, GitHub Secrets support
✅ Fully Extensible: Easy to add new contracts/configurations
Status: ✅ COMPLETE - Ready for production use
Last Updated: February 25, 2026