git ssb


4+

cel / ssb-mutual



Branch:

cel committed 0.1.0Latest: 3c2ac15 on 3/17/2017, 12:59:32 PM
📄README.md
📄index.js
📄package.json
📄schemas.js
📄test.js

ssb-mutual

Mutual credit community currency system for the secure-scuttlebutt network.

Schema

var schemas = require('ssb-mutual/schemas')

type: mutual/credit

Credit another account with an amount of currency, and debit the same from the author's account.

{
  type: "mutual/credit",
  account: Link,
  amount: number|string,
  currency: string,
  memo: string?,
}
var value = schemas.credit(account, amount, currency, memo)
sbot.publish(value, cb)

debit

A debit is represented with the same message type as a credit (mutual/credit), but with a negative amount. There is a helper method in the schemas module:

var value = schemas.debit(account, amount, currency, memo)
sbot.publish(value, cb)

type: mutual/account

An account, whose id may be used in the account property of a mutual/credit message instead of a feed id.

{
  type: "mutual/account",
  name: string?,
  description: string?,
}

When rendering an account, prefer taking the name and description from about messages targeting the account, if there are any.

var value = schemas.account(name, description)
sbot.publish(value, cb)

API

var Mutual = require('ssb-mutual')
var mutual = Mutual.init(sbot, config)
mutual.getAccountBalances(account, cb)

getAccountBalance: async

Get an account's balance for a currency

getAccountBalance({account, currency}, cb)

cb(err, amount)

getAccountBalances: async

Get an account's balances for all currencies

getAccountBalances(account, cb)

cb(err, {<currency>: amount, ...})

getCurrencyBalances: async

Get balances of all accounts for a currency

getCurrencyBalances(currency, cb)

cb(err, {<account>: amount, ...})

streamAccountHistory: source

Get transactions to/from an account.

streamAccountHistory({account, currency, counterparty})
{
  id: MsgId,
  timestamp: number,
  counterparty: Id,
  currency: string,
  amount: string,
  originated: boolean,
  memo: string,
  private: boolean,
}

streamTransactions: source

streamTransactions({currency})
{
  id: MsgId,
  timestamp: number,
  author: FeedId,
  counterparty: Id,
  currency: string,
  amount: string,
  memo: string,
  private: boolean,
}

close: async

close the API and its sbot client

close([err], [cb])

References

License

Copyright (c) 2017 @cel

Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument.

DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.


Built with git-ssb-web