This directory contains automation tooling for deploying runtime guard wrapper contracts to Soroban testnet with continuous validation.
Sanctifier now provides automated deployment of runtime guard wrapper contracts that:
- Wrap target contracts with security guards
- Validate state invariants before and after execution
- Collect execution metrics for auditing
- Monitor continuously with health checks
- Deploy via CLI or GitHub Actions for CI/CD integration
# 1. Configure environment
cp .env.example .env.local
# Edit .env.local with your SOROBAN_SECRET_KEY
# 2. Source environment
source .env.local
# 3. Deploy with continuous validation
./scripts/deploy-soroban-testnet.sh --network testnet
# OR use the CLI
sanctifier deploy contracts/runtime-guard-wrapper \
--network testnet \
--validate-
Add GitHub Secret:
gh secret set SOROBAN_SECRET_KEY --body "SBXXXXXXX..."
-
Push to main or manually trigger:
- Actions tab > Soroban Runtime Guard Deployment > Run workflow
Sanctifier/
├── contracts/runtime-guard-wrapper/ # Runtime guard wrapper contract
│ ├── Cargo.toml # Contract manifest
│ ├── src/lib.rs # Guard implementation
│ └── tests/integration_tests.rs # Test harness
├── tooling/sanctifier-cli/
│ └── src/commands/deploy.rs # Deploy command
├── scripts/
│ └── deploy-soroban-testnet.sh # Deployment automation script
├── .github/workflows/
│ └── soroban-deploy.yml # CI/CD workflow
├── docs/
│ └── soroban-deployment.md # Full documentation
└── .env.example # Environment template
Location: contracts/runtime-guard-wrapper/
A Soroban smart contract that wraps target contracts with runtime validation:
- Guard Execution: Pre/post-execution checks
- Storage Validation: Integrity verification
- Metrics Collection: Call tracking and performance data
- Event Emission: Guard status monitoring
- Health Checks: Continuous validation support
Key features:
// Initialize wrapper with target contract
init(env, wrapped_contract_address)
// Execute with guards
execute_guarded(env, function_name, args) -> Result<Val>
// Get validation stats
get_stats(env) -> (invariants_checked, call_count, failures)
// Health check for continuous monitoring
health_check(env) -> boolLocation: tooling/sanctifier-cli/src/commands/deploy.rs
Integrated into Sanctifier CLI for easy deployment:
sanctifier deploy <PATH> [OPTIONS]
Options:
--network <NETWORK> Target network (testnet, futurenet, mainnet)
--secret-key <KEY> Soroban secret key
--account-id <ID> Account ID (optional)
--validate Run validation after deployment
--output-format Output format (text, json)Location: scripts/deploy-soroban-testnet.sh
Comprehensive shell script for production deployments:
./scripts/deploy-soroban-testnet.sh [OPTIONS]
Options:
--network <NETWORK> Target network (default: testnet)
--no-validate Skip post-deployment validation
--no-continuous Disable continuous validation loop
--dry-run Perform dry run without deployment
--interval <SECONDS> Validation interval (default: 300)
--debug Enable debug loggingFeatures:
- Automatic contract building
- WASM file discovery
- Deployment with retries
- Deployment manifest tracking
- Continuous validation loop
- Detailed logging
Location: .github/workflows/soroban-deploy.yml
Automated CI/CD pipeline that:
- Triggers on push to main or schedule
- Builds and validates WASM artifacts
- Deploys to testnet
- Runs continuous validation
- Generates deployment reports
- Posts status to GitHub
Triggers:
- Push: When runtime-guard-wrapper or deploy script changes
- Schedule: Every 6 hours for continuous validation
- Manual: Via Actions workflow dispatch
┌─────────────────────────────────────────────────────┐
│ 1. Environment Validation │
│ - Check tools (cargo, soroban, jq, curl) │
│ - Verify SOROBAN_SECRET_KEY │
│ - Validate network configuration │
└─────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────┐
│ 2. Contract Building │
│ - Compile Rust to WASM │
│ - Optimize with release profile │
│ - Verify artifact generation │
└─────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────┐
│ 3. Deployment │
│ - Deploy WASM to Soroban testnet │
│ - Retrieve contract ID │
│ - Retry on failure (max 3 attempts) │
└─────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────┐
│ 4. Post-Deployment Validation │
│ - Invoke health_check() on contract │
│ - Verify storage accessibility │
│ - Record deployment success │
└─────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────┐
│ 5. Continuous Validation (Optional) │
│ - Loop every N seconds (default: 300) │
│ - Call health_check() periodically │
│ - Collect execution stats │
│ - Update deployment manifest │
└─────────────────────────────────────────────────────┘
Add these secrets to your repository (Settings > Secrets):
# Required
SOROBAN_SECRET_KEY=SBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Optional (derived if not set)
SOROBAN_ACCOUNT_ID=GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXUsing GitHub CLI:
gh secret set SOROBAN_SECRET_KEY --body "SBXXXXXXX..."# Copy template
cp .env.example .env.local
# Edit with credentials (NEVER commit!)
nano .env.local
# Load before running scripts
source .env.local✅ DO:
- Use GitHub Secrets for sensitive data
- Rotate credentials regularly
- Use separate keys for testnet/mainnet
- Review deployment logs
- Enable branch protection rules
❌ DON'T:
- Commit .env.local to repository
- Share secret keys in messages
- Hardcode credentials in scripts
- Store secrets in plain text
source .env.local
./scripts/deploy-soroban-testnet.sh --network testnet --validateOutput:
✓ Contract built: runtime-guard-wrapper
✓ Contract deployed: CXXXXX...
✓ Health check passed
✓ Contract validation passed
./scripts/deploy-soroban-testnet.sh --dry-run --debug# Validate every 10 minutes instead of default 5
./scripts/deploy-soroban-testnet.sh --interval 600./scripts/deploy-soroban-testnet.sh --no-continuous --validatesanctifier deploy contracts/runtime-guard-wrapper \
--network testnet \
--secret-key "$SOROBAN_SECRET_KEY" \
--validate \
--output-format jsonFile: .deployment-manifest.json
{
"version": "1.0",
"deployments": [
{
"contract_id": "CXXXXX...",
"name": "runtime-guard-wrapper",
"wasm_hash": "abc123...",
"network": "testnet",
"deployed_at": "2026-02-25T12:34:56Z",
"last_validated": "2026-02-25T12:35:10Z",
"status": "active"
}
],
"last_updated": "2026-02-25T12:35:10Z"
}File: .deployment.log
Contains detailed execution logs for auditing:
[INFO] Deployment script started
[INFO] Network: testnet
[✓] Environment validated
[✓] Contract built: runtime-guard-wrapper
[✓] Contract deployed: CXXXXX...
[✓] Validation iteration #1
The continuous validation loop performs:
-
Health Check
- Verifies wrapped contract is set
- Checks metrics storage accessibility
- Returns boolean status
-
Stats Collection
- Invariants checked count
- Call log entries
- Guard failure count
-
Storage Integrity
- Critical keys accessible
- No corruption detected
- State consistency maintained
-
Event Monitoring
- Guard events emitted
- Status tracking
- Failure detection
# Verify environment variable
echo $SOROBAN_SECRET_KEY
# Set if missing
export SOROBAN_SECRET_KEY="SBXXXXXXX..."
# Or load from .env.local
source .env.local# Rebuild contracts
cargo build --release --target wasm32-unknown-unknown
# Verify output
ls -la target/wasm32-unknown-unknown/release/runtime_guard_wrapper.wasm# Check network connectivity
soroban network info --network testnet
# Verify account balance
soroban account balance --account $SOROBAN_ACCOUNT_ID --network testnet
# Check with dry-run
./scripts/deploy-soroban-testnet.sh --dry-run# Increase validation interval
./scripts/deploy-soroban-testnet.sh --interval 600
# Or skip continuous validation
./scripts/deploy-soroban-testnet.sh --no-continuous- Full Deployment Guide
- Runtime Guard Wrapper Contract
- Sanctifier CLI Documentation
- GitHub Actions Workflow
- Soroban Documentation
The workflow runs automatically every 6 hours to validate deployed contracts:
schedule:
- cron: "0 */6 * * *"Trigger deployment manually:
- Go to Actions tab
- Select "Soroban Runtime Guard Deployment"
- Click "Run workflow"
- Select network (testnet/futurenet/mainnet)
- Optionally enable dry-run
Planned support for:
- Multiple networks (testnet, futurenet, mainnet)
- Multiple contract versions
- Performance profiling
- Regression testing
- Build time: ~30-45 seconds
- Deployment: ~10-15 seconds per contract
- Validation: ~5 seconds per check
- Continuous validation loop: Configurable, default 5 minutes
- ✅ Set up environment variables
- ✅ Add GitHub secrets
- ✅ Test local deployment with dry-run
- ✅ Deploy to testnet
- ✅ Monitor validation logs
- ✅ Review deployment manifest
- ✅ Set up scheduled validation
For issues or questions:
- Check Troubleshooting section
- Review deployment logs in
.deployment.log - Check GitHub Actions run logs
- Consult Full Documentation
Last Updated: February 25, 2026 Version: 1.0 Status: Production Ready