npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ssb-mutual

v0.1.0

Published

mutual credit currency system on secure-scuttlebutt

Downloads

4

Readme

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?,
}
  • account: feed id or mutual/account msg id for the account to receive the credit.
  • amount: amount of currency to transfer. may be a number in decimal string format, or a number if this does not lose precision. may be negative.
  • currency: currency type to transfer. may be a three-letter currency code, or a msg id or blob id, or some other string.
  • memo: memo text for the transaction
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?,
}
  • name: name of the account.
  • description: text describing the account

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, ...})
  • account (Ref): account to get a balances for
  • currency (string): currency id
  • amount (string): balance the account has for that curency

getCurrencyBalances: async

Get balances of all accounts for a currency

getCurrencyBalances(currency, cb)

cb(err, {<account>: amount, ...})
  • currency (string): currency to get account balances for
  • account (Ref): account holding a balance with this currency
  • amount (string): balance the account has for this curency

streamAccountHistory: source

Get transactions to/from an account.

streamAccountHistory({account, currency, counterparty})
  • account (Id): id of account to get transactions to/from
  • currency (string, optional): filter transactions by currency
  • counterparty (Id, optional): filter transactions by other account
{
  id: MsgId,
  timestamp: number,
  counterparty: Id,
  currency: string,
  amount: string,
  originated: boolean,
  memo: string,
  private: boolean,
}
  • id: id of the mutual/credit message
  • timestamp: publish time of the message
  • counterparty: the other entity in the transaction
  • currency: currency of the transaction
  • amount: change in account's balance
  • originated: whether account published this transaction (true), or did counterparty (false). if false, amount is the negative of the original transaction amount.
  • memo: memo text for the transaction
  • private: whether the transaction was in a private message (true), or was public (false)

streamTransactions: source

streamTransactions({currency})
  • currency (string, optional): filter transactions by currency
{
  id: MsgId,
  timestamp: number,
  author: FeedId,
  counterparty: Id,
  currency: string,
  amount: string,
  memo: string,
  private: boolean,
}
  • id: id of the mutual/credit message
  • timestamp: publish time of the message
  • author: creator of the transaction
  • counterparty: the other entity in the transaction
  • currency: currency of the transaction
  • amount: amount transfered from author to counterparty
  • memo: memo text for the transaction
  • private: whether the transaction was in a private message, or public

close: async

close the API and its sbot client

close([err], [cb])
  • err error to pass upstream, if any

References

  • Intro discussion thread
  • http://wiki.p2pfoundation.net/Mutual_Credit
  • http://appropriate-economics.org/materials/mutualcreditmanual.html
  • https://github.com/matslats/groupaccounting/wiki/Functional-Requirements

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.