Skip to content

[CON-05] Complete resource_credits Soroban smart contract #1154

Description

@yusuftomilola

Overview

The resource_credits contract enables an on-chain credit ledger for resource usage (printing, meeting room minutes, amenities) but is currently unimplemented. This is the blockchain layer for the credit/hour packs feature.

Context

  • Language: Rust 2021 edition, Soroban SDK (no_std)
  • access_control contract governs who can issue credits — only hub admin should mint
  • Credits are fungible units (represented as i128) that can be issued and spent

Tasks

  • Implement issue_credits(member_address, amount, issued_by) — admin mints credit units to a member's balance
  • Implement spend_credits(member_address, amount, resource_id) — deducts credits; panics if balance insufficient
  • Implement get_balance(member_address) → i128 — returns current balance
  • Implement get_transaction_history(member_address) → Vec of credit events (issue/spend with timestamp and resource_id)
  • Enforce access control: only addresses with admin role (via access_control) can call issue_credits
  • Add contract tests covering: issue, spend, insufficient balance rejection, balance query, history query

Files to Modify / Create

  • contracts/resource_credits/src/ (all source files)

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions