{"_id":"ssb-mutual","_rev":"58-1ab25905e8fa08b687c987b685ff34c6","name":"ssb-mutual","description":"mutual credit currency system on secure-scuttlebutt","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"ssb-mutual","version":"0.1.0","description":"mutual credit currency system on secure-scuttlebutt","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"ssb://%S2HuUuDNIYnmNAK/cNmnhSzhrALoeBEXY4BJwOBTz9s=.sha256"},"dependencies":{"big.js":"^3.1.3","pull-many":"^1.0.8","pull-paramap":"^1.2.1","pull-stream":"^3.5.0","ssb-ref":"^2.6.2"},"devDependencies":{"scuttlebot":"^9.4.4","ssb-config":"^2.2.0","ssb-feed":"^2.3.0","ssb-keys":"^7.0.3","tape":"^4.6.3"},"author":{"name":"cel"},"license":"Fair","gitHead":"3c2ac15a9551710f2d056f5a8576f1328fb1ba60","_id":"ssb-mutual@0.1.0","_shasum":"e22fa279a24222d83557475dd4153c62a50ee2a0","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.1","_npmUser":{"name":"cel","email":"npm.cel@celehner.com"},"maintainers":[{"name":"cel","email":"npm.cel@celehner.com"}],"dist":{"shasum":"e22fa279a24222d83557475dd4153c62a50ee2a0","tarball":"https://registry.npmjs.org/ssb-mutual/-/ssb-mutual-0.1.0.tgz","npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh273YCRA9TVsSAnZWagAAhTIQAIj/g1N5Zcy1nQgVZbn6\nOsu6A4RO946ZNWLL1ubsD6AY5bCPyNenOFT3Yii364SccYzPaAoCfJC8dnVF\nvw7y8GaRc97e+cEWX6Zr3WYBV7A+lkj1QzpoC3Z5y7N431z/tiKodK6LztDK\nOOZqMzZV8pp8y76UbgVQl2rkqlSeePzanu+unq4N4/nqXQpJB+7UbYOj5USc\n+X2kOkei7etdPd/6227tU61LoeneYRx/bH5EfYjiN01BmDlF7bh65yFwLJkR\nEUlBVP+ln+hM6yagiHk2bXXbas+ZCCauxvuwuBR7lqGODSa3xAMbZ4wvMuAX\nsPdzzXZgB6GWJOwE8k73LuxGarKcOhAvKmPt1mA/pWiQm55i9r28suHjAQz5\npVNTlQWPIa2ogRH5cM6MHHe1OcuAx2rQj2DwdFnkgxIN61xIWYkFCQv6CguN\n8icQd/X1rsKK5fzyoRTcIObXPGKbQl28Ik2lAOc0m1qOMBl8gEtmOEVwSupS\naV/plr3l8Da3BsJIKD6TMTCDKj41x2/w0Cx0gqE/U5YxCXxO7yR6Cu93txG4\nEYpUl6QQopkvdftQMc/Cy2PaDQV+XBuN9bLuu7X/WZJGcisgN7WZqdDzukhK\ngv+zMFwNuFwFc7qEj9sezuUCr4Qc5pjaGB2q2YOaCzgLva9axH6zrcdgHfOH\nwrao\r\n=dQRq\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-3JnuMZnk0dkK06mhldWvcbvllXY5MgaXAqgNpJ81LAC/ds9IAIzczIQxTniVXFlEb7U9gNtzTdF+/wu5nKlnpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDL+bagcXf70vozWnol1zSJehYd+hLjKaY+qK1fdXluggIhAJWVL3yrUMBB4igNM6ymFEMXUS0iGAo+Ouvkg+Z5FMWJ"}]},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/ssb-mutual-0.1.0.tgz_1489780868671_0.47397151915356517"},"directories":{}}},"readme":"# ssb-mutual\n\nMutual credit community currency system for the secure-scuttlebutt network.\n\n## Schema\n\n```\nvar schemas = require('ssb-mutual/schemas')\n```\n\n### type: `mutual/credit`\n\nCredit another account with an amount of currency, and debit the same from the author's account.\n\n```js\n{\n  type: \"mutual/credit\",\n  account: Link,\n  amount: number|string,\n  currency: string,\n  memo: string?,\n}\n```\n\n- **account**: feed id or `mutual/account` msg id for the account to receive the credit.\n- **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.\n- **currency**: currency type to transfer. may be a three-letter currency code, or a msg id or blob id, or some other string.\n- **memo**: memo text for the transaction\n\n```\nvar value = schemas.credit(account, amount, currency, memo)\nsbot.publish(value, cb)\n```\n\n#### debit\n\nA 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:\n\n```\nvar value = schemas.debit(account, amount, currency, memo)\nsbot.publish(value, cb)\n```\n\n### type: `mutual/account`\n\nAn account, whose id may be used in the `account` property of a `mutual/credit` message instead of a feed id.\n\n```js\n{\n  type: \"mutual/account\",\n  name: string?,\n  description: string?,\n}\n```\n\n- **name**: name of the account.\n- **description**: text describing the account\n\nWhen rendering an account, prefer taking the name and description from `about` messages targeting the account, if there are any.\n\n```\nvar value = schemas.account(name, description)\nsbot.publish(value, cb)\n```\n\n## API\n\n```\nvar Mutual = require('ssb-mutual')\nvar mutual = Mutual.init(sbot, config)\nmutual.getAccountBalances(account, cb)\n```\n\n### getAccountBalance: async\n\nGet an account's balance for a currency\n\n```\ngetAccountBalance({account, currency}, cb)\n\ncb(err, amount)\n```\n\n### getAccountBalances: async\n\nGet an account's balances for all currencies\n\n```\ngetAccountBalances(account, cb)\n\ncb(err, {<currency>: amount, ...})\n```\n\n- **account** (Ref): account to get a balances for\n- **currency** (string): currency id\n- **amount** (string): balance the account has for that curency\n\n### getCurrencyBalances: async\n\nGet balances of all accounts for a currency\n\n```\ngetCurrencyBalances(currency, cb)\n\ncb(err, {<account>: amount, ...})\n```\n\n- **currency** (string): currency to get account balances for\n- **account** (Ref): account holding a balance with this currency\n- **amount** (string): balance the account has for this curency\n\n### streamAccountHistory: source\n\nGet transactions to/from an account.\n\n```\nstreamAccountHistory({account, currency, counterparty})\n```\n\n- **account** (Id): id of account to get transactions to/from\n- **currency** (string, optional): filter transactions by currency\n- **counterparty** (Id, optional): filter transactions by other account\n\n```\n{\n  id: MsgId,\n  timestamp: number,\n  counterparty: Id,\n  currency: string,\n  amount: string,\n  originated: boolean,\n  memo: string,\n  private: boolean,\n}\n```\n\n- **id**: id of the `mutual/credit` message\n- **timestamp**: publish time of the message\n- **counterparty**: the other entity in the transaction\n- **currency**: currency of the transaction\n- **amount**: change in account's balance\n- **originated**: whether `account` published this transaction (`true`), or did `counterparty` (`false`). if `false`, `amount` is the negative of the original transaction amount.\n- **memo**: memo text for the transaction\n- **private**: whether the transaction was in a private message (`true`), or was public (`false`)\n\n### streamTransactions: source\n\n```\nstreamTransactions({currency})\n```\n\n- **currency** (string, optional): filter transactions by currency\n\n```\n{\n  id: MsgId,\n  timestamp: number,\n  author: FeedId,\n  counterparty: Id,\n  currency: string,\n  amount: string,\n  memo: string,\n  private: boolean,\n}\n```\n\n- **id**: id of the `mutual/credit` message\n- **timestamp**: publish time of the message\n- **author**: creator of the transaction\n- **counterparty**: the other entity in the transaction\n- **currency**: currency of the transaction\n- **amount**: amount transfered from author to counterparty\n- **memo**: memo text for the transaction\n- **private**: whether the transaction was in a private message, or public\n\n### close: async\n\nclose the API and its sbot client\n\n```\nclose([err], [cb])\n```\n\n- **err** error to pass upstream, if any\n\n## References\n\n- [Intro discussion thread](%/4DahnKDhVioNV4oaDdcUqpPCUYd98eCxsBldlHXEXE=.sha256)\n- http://wiki.p2pfoundation.net/Mutual_Credit\n- http://appropriate-economics.org/materials/mutualcreditmanual.html\n- https://github.com/matslats/groupaccounting/wiki/Functional-Requirements\n\n## License\n\nCopyright (c) 2017 [@cel](@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519)\n\nUsage of the works is permitted provided that this instrument\nis retained with the works, so that any entity that uses the\nworks is notified of this instrument.\n\nDISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.\n","maintainers":[{"email":"jacob.karlsson95@gmail.com","name":"powersource"},{"email":"arj03@protonmail.ch","name":"arj03"},{"email":"andre+npm@staltz.com","name":"staltz"},{"email":"whimful@gmail.com","name":"mixmix"},{"email":"npm.cel@celehner.com","name":"cel"}],"time":{"modified":"2022-11-09T11:52:07.941Z","created":"2017-03-17T20:01:09.351Z","0.1.0":"2017-03-17T20:01:09.351Z"},"repository":{"type":"git","url":"ssb://%S2HuUuDNIYnmNAK/cNmnhSzhrALoeBEXY4BJwOBTz9s=.sha256"},"author":{"name":"cel"},"license":"Fair","readmeFilename":"README.md"}