Stellar Soroban smart contracts for the CommitLabs protocol.
This directory contains the core smart contracts for CommitLabs:
- commitment_nft: NFT contract representing liquidity commitments
- commitment_core: Core contract for creating and managing commitments
- attestation_engine: Contract for verifying and recording commitment health
- Rust (latest stable version)
- Stellar Soroban CLI tools
- Cargo
# Build all contracts
cargo build --target wasm32-unknown-unknown --release
# Build individual contract
cd contracts/commitment_nft
cargo build --target wasm32-unknown-unknown --release# Run all tests
cargo test
# Test specific contract
cd contracts/commitment_nft
cargo testGenerate API documentation for all contracts
bash scripts/generate-docs.shThis command runs cargo doc --workspace --no-deps and copies HTML documentation into docs/.
Open the following files in a browser for crate-specific docs:
docs/commitment_nft/index.htmldocs/commitment_core/index.htmldocs/attestation_engine/index.htmldocs/allocation_logic/index.htmldocs/shared_utils/index.html
The docs are generated directly from Rust doc comments (/// and //!) so they stay in sync with the code as it evolves.
You can re-run the script after any changes to regenerate function, parameter, and error documentation, as well as any usage examples included in the comments.
This repository uses GitHub Actions to automatically build, test, and validate Soroban smart contracts on every push to main and every pull request targeting main.
The CI pipeline performs the following steps:
- Checkout the repository
- Install Rust via rustup (stable toolchain)
- Add Soroban target (
wasm32v1-none) for contract compilation - Install Stellar CLI via Homebrew
- Build contracts using both:
- Cargo (
cargo build --target wasm32v1-none --release) - Stellar CLI (
soroban contract build)
- Cargo (
- Run tests (
cargo test --target wasm32v1-none --release)
- On every push to the
mainbranch - On every pull request targeting the
mainbranch
If the CI fails, you can reproduce the same environment locally:
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup default stable
# Add Soroban target
rustup target add wasm32v1-none
# Install Stellar CLI (macOS)
brew tap stellar/stellar-cli
brew install stellar
# Verify installation
stellar --version
soroban --version
# Build contracts
cargo build --target wasm32v1-none --release
# Run tests
cargo test --workspaceThe CI will fail fast on any build errors or test failures, ensuring that only valid code is merged into the main branch.
Deployment is managed via scripts and documented in DEPLOYMENT.md.
# Build all contracts
bash scripts/build-contracts.sh
# Deploy to testnet
bash scripts/deploy-testnet.sh
# Deploy to mainnet
bash scripts/deploy-mainnet.shRepresents a liquidity commitment as an NFT. Each NFT contains:
- Commitment metadata (duration, risk tolerance, type)
- Owner information
- Active status
Manages the lifecycle of commitments:
- Creation with rules
- Value tracking
- Settlement at maturity
- Early exit handling
Continuously verifies commitment health:
- Records attestations
- Tracks health metrics
- Verifies compliance
- Calculates compliance scores
- Implement storage for all contracts
- Add proper access control
- Implement commitment rule enforcement
- Add integration with Stellar asset contracts
- Implement allocation logic
- Add comprehensive tests
- Security audit
MIT