Summary
The trustlesswork-smart-contract-stellar repository (also known as Trustless-Work-Smart-Escrow) currently documents toolchain setup and deployment in the README, but lacks a contract-level reference for contributors, auditors, and integrators who need to understand what the Soroban escrow actually exposes on-chain.
The Trustless Work product docs cover the REST API and SDK flows well, but there is no in-repo bridge between those flows and the contract's public functions, storage model, events, and error enum.
This issue asks for a focused documentation pass inside the smart-contract repo.
Problem
Today, someone cloning the repo must reverse-engineer behavior from Rust source:
contracts/escrow/src/contract.rs — public entrypoints (initialize_escrow, fund_escrow, release_funds, change_milestone_status, approve_milestone, dispute_escrow, resolve_dispute, etc.)
contracts/escrow/src/error.rs — 40+ ContractError variants; human-readable descriptions exist only as commented-out Display impl
contracts/escrow/src/events/handler.rs — on-chain events (InitEsc, FundEsc, DisEsc, MilestoneApproved, …)
contracts/escrow/src/storage/types.rs — Escrow, roles, milestone shape
The README stops after stellar contract deploy and does not explain:
- Repository / branch layout (
single-release-develop, multi-release branches, factory pattern)
- Which wallet role must sign each contract call
- How contract errors map to API error messages
- How to run and interpret the existing test suite (
cargo test in contracts/escrow)
CONTRIBUTORS_GUIDELINE.md also links to outdated paths (Tico4Chain-Coders/Trustless-Work).
Proposed deliverable
Add a new doc (suggested path: docs/CONTRACT_REFERENCE.md) and link it from README.md + CONTRIBUTORS_GUIDELINE.md.
1. Contract overview
- Purpose of the escrow factory + instance pattern (
tw_new_single_release_escrow)
- High-level lifecycle diagram: deploy → initialize → fund → milestone progress → approve → release / dispute → resolve
- Link to relevant product docs:
2. Public interface table
For each exported function in EscrowContract, document:
| Function |
Authorized signer(s) |
Preconditions |
Emitted event(s) |
REST API equivalent (if any) |
initialize_escrow |
deployer / signer |
flags must be false, valid roles |
InitEsc |
/escrow/single-release/v2/deploy |
fund_escrow |
funder (signer) |
escrow not released/resolved |
FundEsc |
fund endpoint |
| … |
… |
… |
… |
… |
Include admin/TTL helpers (extend_contract_ttl, update_escrow) and dispute paths.
3. Storage & roles
- Document
Escrow struct fields and role constraints (e.g. admin must be distinct, max 5 approvers, platform fee ≤ 99%)
- Clarify milestone limits (max 50) and status conventions (
pending → in_progress → completed)
4. Error reference
- Generate a table from
ContractError in error.rs:
- numeric code
- variant name
- human-readable message (restore/uncomment the existing descriptions)
- typical trigger / which function returns it
- Cross-link to API docs where the same error surfaces in HTTP responses
5. Events reference
- List each event struct, payload fields, and when it is published
- Note indexer / explorer relevance for downstream tooling
6. Local development
- How to run tests:
cargo test (from repo root or contracts/escrow)
- Brief map of test modules (
tests/escrow.rs, tests/fund.rs, tests/dispute.rs, …) and what scenario each covers
- Fix broken links in
CONTRIBUTORS_GUIDELINE.md to point to this repo's GIT_GUIDELINE.md
Acceptance criteria
Out of scope
- Rewriting the external GitBook / docs.trustlesswork.com site (link out instead)
- Multi-release branch docs beyond a short "see branch X for multi-release variant" note
- New contract features or code changes beyond uncommenting error descriptions if desired
References
Suggested labels
documentation, good first issue (if the tables are scaffolded by maintainers first)
Summary
The
trustlesswork-smart-contract-stellarrepository (also known asTrustless-Work-Smart-Escrow) currently documents toolchain setup and deployment in the README, but lacks a contract-level reference for contributors, auditors, and integrators who need to understand what the Soroban escrow actually exposes on-chain.The Trustless Work product docs cover the REST API and SDK flows well, but there is no in-repo bridge between those flows and the contract's public functions, storage model, events, and error enum.
This issue asks for a focused documentation pass inside the smart-contract repo.
Problem
Today, someone cloning the repo must reverse-engineer behavior from Rust source:
contracts/escrow/src/contract.rs— public entrypoints (initialize_escrow,fund_escrow,release_funds,change_milestone_status,approve_milestone,dispute_escrow,resolve_dispute, etc.)contracts/escrow/src/error.rs— 40+ContractErrorvariants; human-readable descriptions exist only as commented-outDisplayimplcontracts/escrow/src/events/handler.rs— on-chain events (InitEsc,FundEsc,DisEsc,MilestoneApproved, …)contracts/escrow/src/storage/types.rs—Escrow, roles, milestone shapeThe README stops after
stellar contract deployand does not explain:single-release-develop, multi-release branches, factory pattern)cargo testincontracts/escrow)CONTRIBUTORS_GUIDELINE.mdalso links to outdated paths (Tico4Chain-Coders/Trustless-Work).Proposed deliverable
Add a new doc (suggested path:
docs/CONTRACT_REFERENCE.md) and link it fromREADME.md+CONTRIBUTORS_GUIDELINE.md.1. Contract overview
tw_new_single_release_escrow)2. Public interface table
For each exported function in
EscrowContract, document:initialize_escrowInitEsc/escrow/single-release/v2/deployfund_escrowsigner)FundEscInclude admin/TTL helpers (
extend_contract_ttl,update_escrow) and dispute paths.3. Storage & roles
Escrowstruct fields and role constraints (e.g. admin must be distinct, max 5 approvers, platform fee ≤ 99%)pending→in_progress→completed)4. Error reference
ContractErrorinerror.rs:5. Events reference
6. Local development
cargo test(from repo root orcontracts/escrow)tests/escrow.rs,tests/fund.rs,tests/dispute.rs, …) and what scenario each coversCONTRIBUTORS_GUIDELINE.mdto point to this repo'sGIT_GUIDELINE.mdAcceptance criteria
docs/CONTRACT_REFERENCE.md(or equivalent) exists and is linked from READMEcontract.rsis documented with signer, preconditions, and eventsContractErrorvariants have a human-readable description in the doc (and optionally uncommented inerror.rs)CONTRIBUTORS_GUIDELINE.mdlinks updated to this repositoryOut of scope
References
single-release-developSuggested labels
documentation,good first issue(if the tables are scaffolded by maintainers first)