---
# System prepended metadata

title: RSM Mutual-Credit

---

# RSM Mutual-Credit


## Entries

```rust
enum OfferStatus {
    Pending
    Canceled
    Completed // If it's already accepted
}

struct Offer {
    status: OfferStatus,
    debtor_pub_key,
    creditor_pub_key,
    amount,
}

struct Transaction {
    debtor_pub_key,
    creditor_pub_key,
    amount,
    timestamp,
}
```

## Zome functions

- `create_offer(amount, receiver)`
    - Create `Offer` entry
    - Links `Offer` from the debtor and creditor anchors
    - [Nice to have] Send message to signal creditor
- `cancel_offer(offer_id)`
    - Updates status of the offer
- `accept_offer(offer_id)`
    - If the offer is pending,
        - Create Transaction
        - Link from debtor and creditor anchors to transaction
        - [Nice to have] Send message to signal debtor
- `get_balance(agent_address)`
    - Get links from my anchor to transactions
- `get_my_offers()`
    - Get links from my anchor to offers