Soroban smart contracts for the Credence economic trust protocol. This workspace holds the identity bond and delegation contracts.
Part of Credence. Contracts run on the Stellar network via Soroban. The bond contract is the source of truth for staked amounts and is consumed by the backend reputation engine.
- Rust 1.84+ (with
wasm32-unknown-unknown:rustup target add wasm32-unknown-unknown) - Soroban CLI (
cargo install soroban-cli)
From the repo root:
cd credence-contracts
cargo buildFor Soroban (WASM) build:
cargo build --target wasm32-unknown-unknown --release -p credence_bondRun all workspace tests:
cargo test --workspaceRun specific contract tests:
cargo test -p credence_bond
cargo test -p credence_delegationThe dedicated CI workflow at .github/workflows/contracts-tests.yml runs the full workspace tests on every PR.
Run the contracts-only formatting and lint checks locally before opening a PR:
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warningsThe dedicated CI workflow at .github/workflows/contracts-lints.yml runs the same checks.
contracts/credence_bond/— Identity bond contractcreate_bond()/top_up()/withdraw()/withdraw_early()- Rolling bonds:
request_withdrawal()andrenew_if_rolling() - Tiering:
get_tier()with auto-upgrade/downgrade events - Slashing:
slash()with available-balance enforcement - Emergency:
set_emergency_config(),set_emergency_mode(),emergency_withdraw() - Emergency audit:
get_latest_emergency_record_id(),get_emergency_record()
contracts/credence_delegation/— Delegation contractdocs/— Feature docs (rolling-bonds.md,early-exit.md,slashing.md,tier-system.md,delegation.md,emergency.md)
Known simplifications: See docs/known-simplifications.md for a complete list of intentional limitations and production paths.
Configure network and deploy:
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/credence_bond.wasm \
--source <SECRET_KEY> \
--network <NETWORK>See Stellar Soroban docs for auth and network setup.