Skip to content

Latest commit

 

History

History
83 lines (55 loc) · 2.62 KB

File metadata and controls

83 lines (55 loc) · 2.62 KB

Credence Contracts

Soroban smart contracts for the Credence economic trust protocol. This workspace holds the identity bond and delegation contracts.

About

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.

Prerequisites

Setup

From the repo root:

cargo build

For Soroban (WASM) build:

cargo build --target wasm32-unknown-unknown --release --locked -p credence_bond -p credence_delegation

For the reproducibility check and the CI hash comparison, see docs/wasm-reproducibility.md.

Tests

Run all workspace tests:

cargo test --workspace

Run specific contract tests:

cargo test -p credence_bond
cargo test -p credence_delegation

The dedicated CI workflow at .github/workflows/contracts-tests.yml runs the full workspace tests on every PR.

Linting

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 warnings

The dedicated CI workflow at .github/workflows/contracts-lints.yml runs the same checks.

Project layout

  • contracts/credence_bond/ — Identity bond contract
    • create_bond() / top_up() / withdraw() / withdraw_early()
    • Rolling bonds: request_withdrawal() and renew_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 contract
  • docs/ — 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.

Deploy (Soroban CLI)

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.