npm install bitmark
bitmark
==========
Webcredits is a library for creating decentralized ledgers and payments on the
web.
npm install -g bitmark
credit create
credit genesis
After the tables are in place, the genesis process must be carried out. The standard population script will put 1 million bits in the coinbase which can then be distributed in tranches to the seed users or robots.
credit server
Then go to
*
*
*
*
*
*
Alternatively calls can be placed via the library or command line.
balance
create - creates a database
genesis - seeds a wallet
help - shows help message
insert
[description] [timestamp] - inserts a web credit
reputation
server - starts an express server
websocket - starts a websocket server
Will conform to the values in lib/dbconfig.js
config.dialect = 'mysql';
config.storage = 'credit.db';
config.host = 'localhost';
config.database = 'webcredits';
config.username = 'root';
config.password = '';
config.wallet = 'https://localhost/wallet/test#this';
dialect is the db type
* mysql
* sqlite
* mssql
* mariadb
* postgres
storage is for sqlite defaults to credit.db
* host is host
* database is database name
* username is username
* password is password
* wallet is the wallet that contains the webcredit ledger, api and details
Are supported
Webcredits is a transferable points scoring system. It can be used to provide feedback to the user, throttle actions and allow "gamification" of apps. The system is secure and compatible with the work of the W3C payments groups, so that real incentives may be eventually used. The first versions of the system will only use test credits of negligible monetary value. However, the same code can be used for production systems using full payments.
A wallet consists of a ledger and transactions. Each entry in the ledger is a URI and a positive balance.
Changes are made to the ledger via webcredits.
The genesis state is a starting ledger where one balance, usually the "coinbase" is a non zero account with an emission algorithm. Digital signatures may be included with the webcredits to prove who sent them.
The ledgers and credits can be stored in an LDPC or database. Changes to the ledger are made by adding new transactions, either via HTTP POST or by a direct insert to the database.
The main ontology is the webcredits system
* https://w3id.org/cc
Wallets can be found either from a WebID or from an application configuration using the wallet predicate.
https://w3id.org/cc#wallet
This allows users to launch a wallet app and see their balance, their transaction history, and to make new payments.
The wallet is the main holding structure that points to all the other items. A typical wallet may look as follows:
``
<#this>
a
`
* The api is where you can make RESTful calls for balances and transactions
* The inbox is where you can POST new credits
* The tx is where processed transactions are (optionally) stored
For large scale processing a database can be used. Initially supported databases are:
* sqlite
* mySql
Example schemas
`sql@id
CREATE TABLE Credit (
TEXT,source
TEXT,amount
REAL,currency
VARCHAR(255) DEFAULT 'https://w3id.org/cc#bit',destination
TEXT,timestamp
TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,context
TEXT,description
TEXT,wallet
TEXT
);
CREATE TABLE Ledger (
source TEXT,amount
REAL,currency
VARCHAR(255) DEFAULT 'https://w3id.org/cc#bit',wallet
TEXT
);
CREATE TABLE Genesis (
source TEXT,amount
REAL,currency
VARCHAR(255) DEFAULT 'https://w3id.org/cc#bit',wallet
TEXT
);
`
The default currency is the 'bit' equal to one millionth of a bitcoin.
It is possible to access balances and credits directly from the database.
A RESTful API is also provided for convenience to the database.
It is possible to write records to the database, tho this is not recommended. Better is to use the javascript API.
The javascript API provides a function insert.js that will
* insert a credit into the data store
* get a canonical ID for a data structure
* check no balance goes below zero
* alter the ledger of the source and destination
```
insert.js
The first client used is an open source client side JS project called virtual wallet:
* https://virtualwallet.org/
Objectsetup database
Objectgets the current config
create tables
Objectget credit
createDB function
get balance
genesis initialization
genesis
get balance
get reputation
Today's credits
reputation function
Insert into webcredits
ObjectKind: global function
Returns: Object - sequelize db object
| Param | Type | Description |
| --- | --- | --- |
| dialect | string | type of db mysql|sqlite |
| storage | string | file used for sqlite, default ./credit.db |
ObjectKind: global function
Returns: Object - The config
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| sequelize | Object | db object |
| callback | Object | callback |
ObjectKind: global function
Returns: Object - the web credit if exists
| Param | Type | Description |
| --- | --- | --- |
| credit | Object | the web credit |
| sequelize | Object | the DB connection |
| config | Object | the config |
| callback | Object | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| config | Object | config |
| callback | Object | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| source | String | the source |
| sequelize | Object | sequelize object |
| config | Object | config |
| callback | function | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| config | Object | config |
| callback | function | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| config | Object | config |
| callback | function | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| source | String | the source |
| sequelize | Object | sequelize object |
| config | Object | config |
| callback | function | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| sequelize | Object | db object |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| credit | Object | a web credit |
| sequelize | Object | db connection |
| config | Object | config |
| callback | function | callback |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| config | Object | [description] |
Kind: global function
| Param | Type | Description |
| --- | --- | --- |
| credit | Object | a web credit |
| sequelize | Object | db connection |
| config | Object | config |
| callback | function | callback |