Soroban smart contracts for ChronoPay — time tokenization and scheduling on the Stellar network.
- Time token contract (
contracts/chronopay): Soroban contract for:create_time_slot(professional, start_time, end_time)mint_time_token(slot_id, owner)buy_time_token(token_id, buyer, seller)redeem_time_token(token_id, redeemer)
The contract currently enforces owner-based authorization for token lifecycle operations in contracts/chronopay/src.
mint_time_tokenrequiresownerauthorization and rejects unknown slots.buy_time_tokenrequires bothbuyerandsellerauthorization and rejects transfers from non-owners.redeem_time_tokenrequiresredeemerauthorization and allows redemption only by the current owner.- Redeemed tokens cannot be redeemed again.
- Missing tokens fail explicitly instead of mutating contract state.
Acceptance criteria for the redeem access-control flow:
- Only the current token owner can redeem a token.
- Ownership transfer changes who is allowed to redeem.
- Repeated redemption attempts fail.
- Invalid slot or token identifiers fail without changing ownership or status.
- Automated tests cover success, authorization failure, invalid input, and repeat-action failure paths.
contracts/chronopay/src now applies explicit arithmetic validation in
create_time_slot so timestamp and sequence handling do not rely on Rust's
debug-only overflow behavior.
end_timemust be strictly greater thanstart_time- slot id allocation fails cleanly when the internal sequence reaches
u32::MAX - invalid arithmetic paths return typed contract errors that are covered by tests
Acceptance criteria for this change:
- slot creation succeeds for valid increasing timestamps
- zero-length and inverted time ranges are rejected
- slot sequence overflow is rejected without mutating storage
- the existing mint / buy / redeem stubs continue to behave as before
- Rust (stable)
rustfmt:rustup component add rustfmt- For deployment: Stellar CLI (optional)
# Clone the repo (or use your fork)
git clone <repo-url>
cd chronopay-contracts
# Build
cargo build
# Run tests
cargo test
# Check formatting
cargo fmt --all -- --checkchronopay-contracts/
├── Cargo.toml # Workspace definition
├── contracts/
│ └── chronopay/
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs # Contract logic
│ └── test.rs # Unit tests
└── .github/workflows/
└── ci.yml # CI: fmt, build, test
- Fork the repo and create a branch from
main. - Make changes; keep formatting clean:
cargo fmt. - Ensure tests pass:
cargo test. - Open a pull request. CI must pass (fmt check, build, tests).
On every push and pull request to main, GitHub Actions runs:
- Format:
cargo fmt --all -- --check - Build:
cargo build - Tests:
cargo test
MIT