42 lines
1.0 KiB
Markdown
42 lines
1.0 KiB
Markdown
# hyper-p2p-credit-ledger
|
|
|
|
Gossip-synchronized credit accounts: open, credit, debit, transfer, and balance queries on a shared Hyperswarm topic.
|
|
|
|
**Category:** Applications (economy)
|
|
|
|
**Composes with:** `hyper-p2p-auction-gossip`, `hyper-p2p-marketplace-listing`
|
|
|
|
**Protocol:** `credit-ledger/v1`
|
|
|
|
## When to use
|
|
|
|
Soft-currency or reputation balances that should converge across peers without a central server.
|
|
|
|
## When not to use
|
|
|
|
Strong consistency, double-spend safety, or audit-grade accounting (add consensus or signed operation logs).
|
|
|
|
## Quick start
|
|
|
|
```js
|
|
const { HyperP2PCreditLedger } = require('hyper-p2p-credit-ledger')
|
|
const ledger = new HyperP2PCreditLedger({ topic: 'credits-demo' })
|
|
await ledger.ready()
|
|
ledger.openAccount('alice', 100)
|
|
ledger.transfer('alice', 'bob', 25)
|
|
console.log(ledger.balance('bob')) // 25
|
|
await ledger.close()
|
|
```
|
|
|
|
## Docs
|
|
|
|
- [docs/api.md](docs/api.md)
|
|
- [docs/architecture.md](docs/architecture.md)
|
|
- [examples/basic.js](examples/basic.js)
|
|
|
|
## Test
|
|
|
|
```bash
|
|
npm install && npm test
|
|
```
|