Modules

@fabric/core/services/bitcoinService

Manages interaction with the Bitcoin network.

@fabric/core/services/lightningService

Lightning connectivity.

@fabric/core/services/matrixInterface

Service for interacting with Matrix.

@fabric/core/services/shyftService

Manages interactivity with the Shyft network.

Classes

Actor

Generic Fabric Actor.

AppScribe

Web-friendly application framework for building single-page applications with Fabric-based networking and storage.

Chain

Chain.

Channel

The Channel is a encrypted connection with a member of your Peer group, with some amount of $BTC bonded and paid for each correctly-validated message.

Channels in Fabric are powerful tools for application development, as they can empower users with income opportunities in exchange for delivering service to the network.

Circuit

The Circuit is the mechanism through which Fabric operates, a computable directed graph describing a network of Peer components and their interactions (side effects). See also Swarm for deeper *inspection of Machine mechanics.

CLI

Provides a Command Line Interface (CLI) for interacting with the Fabric network using a terminal emulator.

Collection

The Collection type maintains an ordered list of State items.

Compiler : Actor

Compilers build interfaces for users of Fabric applications.

Consensus

Provides various network-specific rules.

Entity : Object

Live instance of an ARC in Fabric.

Fabric

Reliable decentralized infrastructure.

Hash256

Simple interaction with 256-bit spaces.

HKDF

Provides an HMAC-based Extract-and-Expand Key Derivation Function (HKDF), compatible with RFC 5869. Defaults to 32 byte output, matching Bitcoin's implementaton.

InterfaceEventEmitter

Interfaces compile abstract contract code into Chain-executable transactions, or "chaincode". For example, the "Bitcoin" interface might compile a Swap contract into Script, preparing a valid Bitcoin transaction for broadcast which executes the swap contract.

Key

Represents a cryptographic key.

LedgerScribe

An ordered stack of pages.

Machine

General-purpose state machine with Vector-based instructions.

Mempool

Stores a list of Transaction elements.

Message : Object

The Message type defines the Application Messaging Protocol, or AMP. Each Actor in the network receives and broadcasts messages, selectively disclosing new routes to peers which may have open circuits.

OracleStore

An Oracle manages one or more collections, using a mempool for transitive state.

Path

A Path is a Fabric-native link to a Document within the network.

Peer

An in-memory representation of a node in our network.

Remote : Remote

Interact with a remote Resource.

Resource

Generic interface for collections of digital objects.

RouterScribe

Process incoming messages.

ScribeState

Simple tag-based recordkeeper.

Script
Service

The "Service" is a simple model for processing messages in a distributed system. Service instances are public interfaces for outside systems, and typically advertise their presence to the network.

To implement a Service, you will typically need to implement all methods from this prototype. In general, connect and send are the highest-priority jobs, and by default the fabric property will serve as an I/O stream using familiar semantics.

Session

The Session type describes a connection between Peer objects, and includes its own lifecycle.

Snapshot

A type of message to be expected from a Service.

Stack

Manage stacks of data.

StateEventEmitter

The State is the core of most User-facing interactions. To interact with the User, simply propose a change in the state by committing to the outcome. This workflow keeps app design quite simple!

Storage

Persistent data storage.

Store

Long-term storage.

Swap : Object

The Swap contract executes a set of transactions on two distinct Chain components, utilizing a secret-reveal mechanism to atomically execute either the full set or none.

Swarm : String

Orchestrates a network of peers.

Transition

The Transition type reflects a change from one finite State to another.

Value

Number-like type.

Vector
Walker
Wallet : Object

Manage keys and track their balances.

Worker

Workers are arbitrary containers for processing data. They can be thought of almost like "threads", as they run asynchronously over the duration of a contract's lifetime as "fulfillment conditions" for its closure.

Exchange

Implements a basic Exchange.

@fabric/core/services/bitcoin ⇐ Service

Manages interaction with the Bitcoin network.

Extends: Service

@fabric/core/services/bitcoin~Bitcoin

Kind: inner class of <code>@fabric/core/services/bitcoin</code>

new Bitcoin([settings])

Creates an instance of the Bitcoin service.

Param Type Description
[settings] Object Map of configuration options for the Bitcoin service.
[settings.network] String One of regtest, testnet, or mainnet.
[settings.nodes] Array List of address:port pairs to trust.
[settings.seeds] Array Bitcoin peers to request chain from (address:port).
[settings.fullnode] Boolean Run a full node.

bitcoin._prepareTransaction(obj)

Prepares a Transaction for storage.

Kind: instance method of Bitcoin

Param Type Description
obj Transaction Transaction to prepare.

bitcoin._handleCommittedBlock(block)

Receive a committed block.

Kind: instance method of Bitcoin

Param Type Description
block Block Block to handle.

bitcoin._handlePeerPacket(msg)

Process a message from a peer in the Bitcoin network.

Kind: instance method of Bitcoin

Param Type Description
msg PeerPacket Message from peer.

bitcoin._handleBlockFromSPV(msg)

Hand a Block message as supplied by an SPV client.

Kind: instance method of Bitcoin

Param Type Description
msg BlockMessage A Message as passed by the SPV source.

bitcoin._handleTransactionFromSPV(tx)

Verify and interpret a BitcoinTransaction, as received from an SPVSource.

Kind: instance method of Bitcoin

Param Type Description
tx BitcoinTransaction Incoming transaction from the SPV source.

bitcoin._subscribeToShard(shard)

Attach event handlers for a supplied list of addresses.

Kind: instance method of Bitcoin

Param Type Description
shard Shard List of addresses to monitor.

bitcoin._connectSPV()

Initiate outbound connections to configured SPV nodes.

Kind: instance method of Bitcoin

bitcoin.connect(addr)

Connect to a Fabric Peer.

Kind: instance method of Bitcoin

Param Type Description
addr String Address to connect to.

bitcoin.start()

Start the Bitcoin service, including the initiation of outbound requests.

Kind: instance method of Bitcoin

bitcoin.stop()

Stop the Bitcoin service.

Kind: instance method of Bitcoin

@fabric/core/services/lightning ⇐ Service

Lightning connectivity.

Extends: Service

@fabric/core/services/matrix ⇐ Interface

Service for interacting with Matrix.

Extends: Interface

@fabric/core/services/matrix~Matrix

Kind: inner class of <code>@fabric/core/services/matrix</code>

new Matrix([settings])

Create an instance of a Matrix client, connect to the network, and relay messages received from therein.

Param Type Description
[settings] Object Configuration values.

matrix.state

Getter for State.

Kind: instance property of Matrix

matrix.start()

Start the service, including the initiation of an outbound connection to any peers designated in the service's configuration.

Kind: instance method of Matrix

matrix.stop()

Stop the service.

Kind: instance method of Matrix

@fabric/core/services/shyft ⇐ Service

Manages interactivity with the Shyft network.

Extends: Service

@fabric/core/services/shyft~Shyft

Kind: inner class of <code>@fabric/core/services/shyft</code>

new Shyft()

Create a new instance of the Shyft service.

Actor

Generic Fabric Actor.

Kind: global class
Emits: event:message Fabric {@link Message} objects.
Properties

Name Type Description
id String Unique identifier for this Actor.

new Actor([actor])

Creates an Actor, which emits messages for other Actors to subscribe to. You can supply certain parameters for the actor, including key material [!!!] — be mindful of what you share with others!

Param Type Description
[actor] Object Object to use as the actor.
[actor.seed] String BIP24 Mnemonic to use as a seed phrase.
[actor.public] Buffer Public key.
[actor.private] Buffer Private key.

actor.toBuffer() ⇒ Buffer

Casts the Actor to a normalized Buffer.

Kind: instance method of Actor

actor.sign() ⇒ Actor

Signs the Actor.

Kind: instance method of Actor

App ⇐ Scribe

Web-friendly application framework for building single-page applications with Fabric-based networking and storage.

Kind: global class
Extends: Scribe
Properties

Name Type Description
components Collection Interface elements.
stash Store Routable Datastore.

new App(definition)

Generic bundle for building Fabric applications.

Param Type Description
definition Object Application definition. See config for examples.

app.id : Boolean

Identity function.

Kind: instance property of App

app.start() ⇒ Promise

Start the program.

Kind: instance method of App

app.stop() ⇒ Promise

Stop the program.

Kind: instance method of App

app.define(name, structure) ⇒ Object

Define a Resource, or "Type", used by the application.

Kind: instance method of App
Returns: Object - [description]

Param Type Description
name String Human-friendly name for the Resource.
structure Object Map of attribute names -> definitions.

app.defer(authority) ⇒ App

Defer control of this application to an outside authority.

Kind: instance method of App
Returns: App - The configured application as deferred to authority.

Param Type Description
authority String Hostname to trust.

app.attach(element) ⇒ App

Configure the Application to use a specific element.

Kind: instance method of App
Returns: App - Configured instance of the Application.

Param Type Description
element DOMElement DOM element to bind to.

app.consume(resources) ⇒ App

Define the Application's resources from an existing resource map.

Kind: instance method of App
Returns: App - Configured instance of the Application.

Param Type Description
resources Object Map of resource definitions by name.

app.envelop(selector) ⇒ App

Use a CSS selector to find an element in the current document's tree and bind to it as the render target.

Kind: instance method of App
Returns: App - Instance of app with bound element.

Param Type Description
selector String CSS selector.

app.use(name, definition) ⇒ App

Define a named Resource.

Kind: instance method of App
Returns: App - Configurated instance of the App.

Param Type Description
name String Human-friendly name for this resource.
definition Object Map of configuration values.

app.render() ⇒ String

Get the output of our program.

Kind: instance method of App
Overrides: render
Returns: String - Output of the program.

app.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of App
Returns: Number - Number representation of the millisecond Integer value.

app.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of App
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

app.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of App
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

app.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of App
Returns: String - Serialized Blob.

app.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of App
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

app.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of App
Returns: State - [description]

Param Type Description
input String [description]

app.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of App

app.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of App

Param Type Description
path Path Key to retrieve.

app.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of App

Param Type Description
path Path Key to retrieve.

app.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of App

Chain

Chain.

Kind: global class
Properties

Name Type Description
name String Current name.
indices Map
ledger Ledger
storage Storage

new Chain(genesis)

Holds an immutable chain of events.

Param Type Description
genesis Vector Initial state for the chain of events.

Channel

The Channel is a encrypted connection with a member of your Peer group, with some amount of $BTC bonded and paid for each correctly-validated message.

Channels in Fabric are powerful tools for application development, as they can empower users with income opportunities in exchange for delivering service to the network.

Kind: global class

new Channel([settings])

Creates a channel between two peers. of many transactions over time, to be settled on-chain later.

Param Type Description
[settings] Object Configuration for the channel.

channel.add(amount)

Add an amount to the channel's balance.

Kind: instance method of Channel

Param Type Description
amount Number Amount value to add to current outgoing balance.

channel.fund(input)

Fund the channel.

Kind: instance method of Channel

Param Type Description
input Mixed Instance of a Transaction.

channel.open(channel)

Opens a Channel with a Peer.

Kind: instance method of Channel

Param Type Description
channel Object Channel settings.

Circuit

The Circuit is the mechanism through which Fabric operates, a computable directed graph describing a network of Peer components and their interactions (side effects). See also Swarm for deeper *inspection of Machine mechanics.

Kind: global class

CLI

Provides a Command Line Interface (CLI) for interacting with the Fabric network using a terminal emulator.

Kind: global class

new CLI([settings])

Create a terminal-based interface for a User.

Param Type Description
[settings] Object Configuration values.
[settings.currencies] Array List of currencies to support.

clI.start()

Starts (and renders) the CLI.

Kind: instance method of CLI

clI.stop()

Disconnect all interfaces and exit the process.

Kind: instance method of CLI

Collection

The Collection type maintains an ordered list of State items.

Kind: global class
Properties

Name Type Description
@entity Object Fabric-bound entity object.

new Collection([configuration])

Create a list of Entity-like objects for later retrieval.

Param Type Default Description
[configuration] Object {} Configuration object.

collection.asMerkleTree() ⇒ MerkleTree

Current elements of the collection as a MerkleTree.

Kind: instance method of Collection

collection._setKey(name)

Sets the key property of collection settings.

Kind: instance method of Collection

Param Type Description
name String Value to set the key setting to.

collection.getByID(id)

Retrieve an element from the collection by ID.

Kind: instance method of Collection

Param Type Description
id String Document identifier.

collection.getLatest()

Retrieve the most recent element in the collection.

Kind: instance method of Collection

collection.findByField(name, value)

Find a document by specific field.

Kind: instance method of Collection

Param Type Description
name String Name of field to search.
value String Value to match.

collection.findByName(name)

Find a document by the "name" field.

Kind: instance method of Collection

Param Type Description
name String Name to search for.

collection.findBySymbol(symbol)

Find a document by the "symbol" field.

Kind: instance method of Collection

Param Type Description
symbol String Value to search for.

collection._patchTarget(path, patches)

Modify a target document using an array of atomic updates.

Kind: instance method of Collection

Param Type Description
path String Path to the document to modify.
patches Array List of operations to apply.

collection.push(data) ⇒ Number

Adds an Entity to the Collection.

Kind: instance method of Collection
Returns: Number - Length of the collection.

Param Type Description
data Mixed Entity to add.

collection.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Collection

Param Type Description
path Path Key to retrieve.

collection.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Collection

Param Type Description
path Path Key to retrieve.

collection.list() ⇒ Array

Deprecated

Generate a list of elements in the collection.

Kind: instance method of Collection

collection.toTypedArray()

Provides the Collection as an Array of typed elements. The type of these elments are defined by the collection's type, supplied in the constructor.

Kind: instance method of Collection

collection.map() ⇒ Array

Generate a hashtable of elements in the collection.

Kind: instance method of Collection

collection.create(entity) ⇒ Promise

Create an instance of an Entity.

Kind: instance method of Collection
Returns: Promise - Resolves with instantiated Entity.

Param Type Description
entity Object Object with properties.

collection.import(state, commit)

Loads State into memory.

Kind: instance method of Collection
Emits: event:message Will emit one {@link Snapshot} message.

Param Type Description
state State State to import.
commit Boolean Whether or not to commit the result.

Compiler : Actor

Compilers build interfaces for users of Fabric applications.

Kind: global class
Properties

Name Type Description
ast AST Compiler's current AST.
entity Entity Compiler's current Entity.

new Compiler(settings)

Create a new Compiler.

Param Type Default Description
settings Object {} Configuration.
settings.body Buffer Body of the input program to compile.

compiler._getJavaScriptAST(input) ⇒ AST

Parse a Buffer of JavaScript into an Abstract Syntax Tree (AST).

Kind: instance method of Compiler

Param Type Description
input Buffer Input JavaScript to parse.

Compiler._fromJavaScript(body) ⇒

Creates a new Compiler instance from a JavaScript contract.

Kind: static method of Compiler
Returns: Compiler

Param Type Description
body Buffer Content of the JavaScript to evaluate.

Consensus

Provides various network-specific rules.

Kind: global class

new Consensus([settings])

Create an instance of a Consensus verifier.

Param Type Description
[settings] Object Configuration for the network.
[settings.network] String Name of the network.
[settings.provider] String Name of the source provider.

Entity : Object

Live instance of an ARC in Fabric.

Kind: global class

new Entity([data])

Generic template for virtual objects.

Param Type Default Description
[data] Object {} Pass an object to use.

entity.toJSON() ⇒ String

Produces a string of JSON, representing the entity.

Kind: instance method of Entity
Returns: String - JSON-encoded object.

entity.toRaw() ⇒ Buffer

As a Buffer.

Kind: instance method of Entity
Returns: Buffer - Slice of memory.

entity._downsample([input])

Return a Fabric-labeled Object for this Entity.

Kind: instance method of Entity

Param Type Description
[input] Mixed Input to downsample. If not provided, current Entity will be used.

Fabric

Reliable decentralized infrastructure.

Kind: global class
Properties

Name Type
Block Class

new Fabric(config)

The Fabric type implements a peer-to-peer protocol for establishing and settling of mutually-agreed upon proofs of work. Contract execution takes place in the local node first, then is optionally shared with the network.

Utilizing

Param Type Description
config Vector Initial configuration for the Fabric engine. This can be considered the "genesis" state for any contract using the system. If a chain of events is maintained over long periods of time, state can be considered "in contention", and it is demonstrated that the outstanding value of the contract remains to be settled.

fabric.register(service)

Register an available Service using an ES6 Class.

Kind: instance method of Fabric

Param Type Description
service Class The ES6 Class.

fabric.push(value) ⇒ Stack

Push an instruction onto the stack.

Kind: instance method of Fabric

Param Type
value Instruction

fabric.trust(source) ⇒ Fabric

Blindly consume messages from a Source, relying on this.chain to verify results.

Kind: instance method of Fabric
Returns: Fabric - Returns itself.

Param Type Description
source EventEmitter Any object which implements the EventEmitter pattern.

fabric.compute() ⇒ Fabric

Process the current stack.

Kind: instance method of Fabric
Returns: Fabric - Resulting instance of the stack.

Hash256

Simple interaction with 256-bit spaces.

Kind: global class

new Hash256(settings)

Create an instance of a Hash256 object by calling new Hash256(), where settings can be provided to supply a particular input object.

If the settings is not a string, input must be provided.

Param Type Description
settings Object
settings.input String Input string to map as 256-bit hash.

Hash256.digest(input) ⇒ String

Produce a SHA256 digest of some input data.

Kind: static method of Hash256
Returns: String - SHA256(input) as a hexadecimal string.

Param Type Description
input String \ Buffer Content to digest.

HKDF

Provides an HMAC-based Extract-and-Expand Key Derivation Function (HKDF), compatible with RFC 5869. Defaults to 32 byte output, matching Bitcoin's implementaton.

Kind: global class

new HKDF(settings)

Create an HKDF instance.

Param Type Default Description
settings Object List of settings.
settings.initial String Input keying material.
[settings.algorithm] String sha256 Name of the hashing algorithm to use.
[settings.salt] String Salt value (a non-secret random value).

hkdF.derive([info], [size])

Derive a new output.

Kind: instance method of HKDF

Param Type Default Description
[info] Buffer Context and application specific information.
[size] Number 32 Length of output.

Interface ⇐ EventEmitter

Interfaces compile abstract contract code into Chain-executable transactions, or "chaincode". For example, the "Bitcoin" interface might compile a Swap contract into Script, preparing a valid Bitcoin transaction for broadcast which executes the swap contract.

Kind: global class
Extends: EventEmitter
Properties

Name Type Description
status String Human-friendly value representing the Interface's current State.

new Interface(settings)

Define an Interface by creating an instance of this class.

Param Type Description
settings Object Configuration values.

interface.start()

Start the Interface.

Kind: instance method of Interface

interface.stop()

Stop the Interface.

Kind: instance method of Interface

interface.cycle(val)

Ticks the clock with a named Cycle.

Kind: instance method of Interface

Param Type Description
val String Name of cycle to scribe.

interface.log(...inputs)

Log some output to the console.

Kind: instance method of Interface

Param Type Description
...inputs any Components of the message to long. Can be a single {@link} String, many String objects, or anything else.

interface.now() ⇒ Number

Returns current timestamp.

Kind: instance method of Interface

Key

Represents a cryptographic key.

Kind: global class

new Key([settings])

Create an instance of a Fabric Key, either restoring from some known values or from prior knowledge. For instance, you can call new Key() to create a fresh keypair, or new Key({ public: 'deadbeef...' }) to create it from a known public key.

Param Type Description
[settings] Object Initialization for the key.
[settings.network] String Network string.
[settings.seed] String Mnemonic seed for initializing the key.
[settings.public] String Public key in hex.
[settings.private] String Private key in hex.

Ledger ⇐ Scribe

An ordered stack of pages.

Kind: global class
Extends: Scribe
Properties

Name Type Description
memory Buffer The ledger's memory (4096 bytes).
stack Stack The ledger's stack.
tip Mixed The most recent page in the ledger.

ledger.id : Boolean

Identity function.

Kind: instance property of Ledger

ledger.append(item) ⇒ Promise

Attempts to append a Page to the ledger.

Kind: instance method of Ledger
Returns: Promise - Resolves after the change has been committed.

Param Type Description
item Mixed Item to store.

ledger.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Ledger
Returns: Number - Number representation of the millisecond Integer value.

ledger.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Ledger
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

ledger.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Ledger
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

ledger.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Ledger
Returns: String - Serialized Blob.

ledger.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Ledger
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

ledger.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Ledger
Returns: State - [description]

Param Type Description
input String [description]

ledger.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Ledger

ledger.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Ledger

Param Type Description
path Path Key to retrieve.

ledger.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Ledger

Param Type Description
path Path Key to retrieve.

ledger.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Ledger
Overrides: commit

ledger.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Ledger
Overrides: render
Returns: String - JSON-encoded String.

Machine

General-purpose state machine with Vector-based instructions.

Kind: global class

new Machine(config)

Create a Machine.

Param Type Description
config Object Run-time configuration.

machine.sip([n]) ⇒ Number

Get n bits of entropy.

Kind: instance method of Machine
Returns: Number - Random bits from Generator.

Param Type Default Description
[n] Number 32 Number of bits to retrieve (max = 32).

machine.compute(input) ⇒ Promise

Computes the next "step" for our current Vector. Analagous to sum. The top item on the stack is always the memory held at current position, so counts should always begin with 0.

Kind: instance method of Machine

Param Type Description
input Vector Input state, undefined if desired.

Mempool

Stores a list of Transaction elements.

Kind: global class
Emits: event:{Message} confirmed Emitted when the Mempool has dropped a transaction.

new Mempool(settings)

Creates an instance of a Mempool Service.

Param Type Description
settings Object Map of settings to utilize.

Message : Object

The Message type defines the Application Messaging Protocol, or AMP. Each Actor in the network receives and broadcasts messages, selectively disclosing new routes to peers which may have open circuits.

Kind: global class

new Message(message)

The Message type is standardized in Fabric as a Vector, which can be added to any other vector to compute a resulting state.

Param Type Description
message Vector Message vector. Will be serialized by _serialize.

message.asRaw() ⇒ Buffer

Returns a Buffer of the complete message.

Kind: instance method of Message
Returns: Buffer - Buffer of the encoded Message.

Oracle ⇐ Store

An Oracle manages one or more collections, using a mempool for transitive state.

Kind: global class
Extends: Store

new Oracle(initial)

Trusted point-of-reference for external services.

Param Type Description
initial Object Initialization vector.

oracle.broadcast(msg) ⇒ Boolean

Core messaging function for interacting with this object in system-time.

Kind: instance method of Oracle
Returns: Boolean - Returns true on success, false on failure.

Param Type Description
msg Message Instance of a module:Message object, validated then transmitted verbatim.

oracle._REGISTER(obj) ⇒ Vector

Registers an Actor. Necessary to store in a collection.

Kind: instance method of Oracle
Returns: Vector - Returned from storage.set

Param Type Description
obj Object Instance of the object to store.

oracle._POST(key, value) ⇒ Promise

Insert something into a collection.

Kind: instance method of Oracle
Returns: Promise - Resolves on success with a String pointer.

Param Type Description
key String Path to add data to.
value Mixed Object to store.

oracle.get(key) ⇒ Promise

Barebones getter.

Kind: instance method of Oracle
Returns: Promise - Resolves on complete. null if not found.

Param Type Description
key String Name of data to retrieve.

oracle.set(key, value)

Set a key to a specific value.

Kind: instance method of Oracle

Param Type Description
key String Address of the information.
value Mixed Content to store at key.

oracle.trust(source) ⇒ Store

Implicitly trust an Event source.

Kind: instance method of Oracle
Returns: Store - Resulting instance of Store with new trust.

Param Type Description
source EventEmitter Event-emitting source.

oracle.del(key)

Remove a Value by Path.

Kind: instance method of Oracle

Param Type Description
key Path Key to remove.

oracle.flush()

Wipes the storage.

Kind: instance method of Oracle
Overrides: flush

oracle.start() ⇒ Promise

Start running the process.

Kind: instance method of Oracle
Overrides: start
Returns: Promise - Resolves on complete.

Path

A Path is a Fabric-native link to a Document within the network.

Kind: global class

new Path(input)

Create a new Path.

Param Type Description
input String \ Object Named path.

path.isValid() ⇒ Boolean

Kind: instance method of Path
Returns: Boolean - Whether or not the Path is valid.

Peer

An in-memory representation of a node in our network.

Kind: global class

new Peer([config])

Create an instance of Peer.

Param Type Default Description
[config] Object Initialization Vector for this peer.
[config.listen] Boolean Whether or not to listen for connections.
[config.upnp] Boolean Whether or not to use UPNP for automatic configuration.
[config.port] Number 7777 Port to use for P2P connections.
[config.peers] Array [] List of initial peers.

peer.start()

Start the Peer.

Kind: instance method of Peer

peer.stop()

Stop the peer.

Kind: instance method of Peer

peer.listen() ⇒ Peer

Start listening for connections.

Kind: instance method of Peer
Returns: Peer - Chainable method.
Emits: Peer#event:ready

Remote : Remote

Interact with a remote Resource.

Kind: global class
Properties

Name Type
config Object
secure Boolean

new Remote(target)

An in-memory representation of a node in our network.

Param Type Description
target Object Target object.
target.host String Named host, e.g. "localhost".
target.secure String Require TLS session.

remote.enumerate() ⇒ Configuration

Enumerate the available Resources on the remote host.

Kind: instance method of Remote

remote._PUT(path, body) ⇒ Mixed

HTTP PUT against the configured Authority.

Kind: instance method of Remote
Returns: Mixed - [description]

Param Type Description
path String HTTP Path to request.
body Object Map of parameters to supply.

remote._GET(path, params) ⇒ Mixed

HTTP GET against the configured Authority.

Kind: instance method of Remote
Returns: Mixed - [description]

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._POST(path, params) ⇒ Mixed

HTTP POST against the configured Authority.

Kind: instance method of Remote
Returns: Mixed - Result of request.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._OPTIONS(path, params) ⇒ Object

HTTP OPTIONS on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._PATCH(path, body) ⇒ Object

HTTP PATCH on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
body Object Map of parameters to supply.

remote._DELETE(path, params) ⇒ Object

HTTP DELETE on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

Resource

Generic interface for collections of digital objects.

Kind: global class

new Resource(definition)

Param Type Description
definition Object Initial parameters

resource.create(obj) ⇒ Vector

Create an instance of the Resource's type.

Kind: instance method of Resource
Returns: Vector - Resulting Vector with deterministic identifier.

Param Type Description
obj Object Map of the instance's properties and values.

resource.update(id, update) ⇒ Vector

Modify an existing instance of a Resource by its unique identifier. Produces a new instance.

Kind: instance method of Resource
Returns: Vector - Resulting Vector instance with updated identifier.

Param Type Description
id String Unique ID to update.
update Object Map of change to make (keys -> values).

Router ⇐ Scribe

Process incoming messages.

Kind: global class
Extends: Scribe

new Router(map)

Maintains a list of triggers ("commands") and their behaviors.

Param Type Description
map Object Map of command names => behaviors.

router.id : Boolean

Identity function.

Kind: instance property of Router

router.route(msg) ⇒ Array

Assembles a list of possible responses to the incoming request.

Kind: instance method of Router
Returns: Array - List of outputs generated from the input string.

Param Type Description
msg String Input message to route.

router.use(plugin, name) ⇒ Router

Attaches a new handler to the router.

Kind: instance method of Router
Returns: Router - Configured instance of the router.

Param Type Description
plugin Plugin Instance of the plugin.
name Plugin.name Name of the plugin.

router.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Router
Returns: Number - Number representation of the millisecond Integer value.

router.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Router
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

router.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Router
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

router.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Router
Returns: String - Serialized Blob.

router.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Router
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

router.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Router
Returns: State - [description]

Param Type Description
input String [description]

router.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Router

router.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Router

Param Type Description
path Path Key to retrieve.

router.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Router

Param Type Description
path Path Key to retrieve.

router.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Router

router.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Router
Returns: String - JSON-encoded String.

Scribe ⇐ State

Simple tag-based recordkeeper.

Kind: global class
Extends: State
Properties

Name Type Description
config Object Current configuration.

new Scribe(config)

The "Scribe" is a simple tag-based recordkeeper.

Param Type Description
config Object General configuration object.
config.verbose Boolean Should the Scribe be noisy?

scribe.id : Boolean

Identity function.

Kind: instance property of Scribe

scribe.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Scribe
Returns: Number - Number representation of the millisecond Integer value.

scribe.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Scribe
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

scribe.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Scribe
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

scribe.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Scribe
Returns: String - Serialized Blob.

scribe.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Scribe
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

scribe.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Scribe
Returns: State - [description]

Param Type Description
input String [description]

scribe.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Scribe

scribe.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Scribe

Param Type Description
path Path Key to retrieve.

scribe.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Scribe

Param Type Description
path Path Key to retrieve.

scribe.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Scribe

scribe.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Scribe
Returns: String - JSON-encoded String.

Script

Kind: global class

new Script(config)

Compose a Script for inclusion within a Contract.

Returns: Script - Instance of the Script, ready for use.

Param Type Description
config Mixed Configuration options for the script.

Service

The "Service" is a simple model for processing messages in a distributed system. Service instances are public interfaces for outside systems, and typically advertise their presence to the network.

To implement a Service, you will typically need to implement all methods from this prototype. In general, connect and send are the highest-priority jobs, and by default the fabric property will serve as an I/O stream using familiar semantics.

Kind: global class
Properties

Name Description
map The "map" is a hashtable of "key" => "value" pairs.

new Service(config)

Create an instance of a Service.

Param Type Default Description
config Object Configuration for this service.
[config.networking] Boolean true Whether or not to connect to the network.
[config.@data] Object Internal data to assign.

service.handler(message) ⇒ Service

Default route handler for an incoming message. Follows the Activity Streams 2.0 spec: https://www.w3.org/TR/activitystreams-core/

Kind: instance method of Service
Returns: Service - Chainable method.

Param Type Description
message Activity Message object.

service.route(msg) ⇒ Promise

Resolve a State from a particular Message object.

Kind: instance method of Service
Returns: Promise - Resolves with resulting State.

Param Type Description
msg Message Explicit Fabric Message.

service.start()

Start the service, including the initiation of an outbound connection to any peers designated in the service's configuration.

Kind: instance method of Service

service._GET(path) ⇒ Promise

Retrieve a value from the Service's state.

Kind: instance method of Service
Returns: Promise - Resolves with the result.

Param Type Description
path String Path of the value to retrieve.

service._PUT(path, value, [commit]) ⇒ Promise

Store a value in the Service's state.

Kind: instance method of Service
Returns: Promise - Resolves with with stored document.

Param Type Default Description
path String Path to store the value at.
value Object Document to store.
[commit] Boolean false Sign the resulting state.

service.connect(notify) ⇒ Promise

Attach to network.

Kind: instance method of Service
Returns: Promise - Resolves to Fabric.

Param Type Default Description
notify Boolean true Commit to changes.

service.send(channel, message) ⇒ Service

Send a message to a channel.

Kind: instance method of Service
Returns: Service - Chainable method.

Param Type Description
channel String Channel name to which the message will be sent.
message String Content of the message to send.

service._registerActor(actor) ⇒ Promise

Register an Actor with the Service.

Kind: instance method of Service
Returns: Promise - Resolves upon successful registration.

Param Type Description
actor Object Instance of the Actor.

service._send(message)

Sends a message.

Kind: instance method of Service

Param Type Description
message Mixed Message to send.

Session

The Session type describes a connection between Peer objects, and includes its own lifecycle.

Kind: global class

new Session(settings)

Creates a new Session.

Param Type
settings Object

session.start()

Opens the Session for interaction.

Kind: instance method of Session

session.stop()

Closes the Session, preventing further interaction.

Kind: instance method of Session

Snapshot

A type of message to be expected from a Service.

Kind: global class

new Snapshot(settings)

Creates an instance of a Snapshot.

Param Type Description
settings Object Map of settings to configure the Snapshot with.

snapshot.commit()

Retrieves the sha256 fingerprint for the Snapshot state.

Kind: instance method of Snapshot

Stack

Manage stacks of data.

Kind: global class

new Stack([list])

Create a Stack instance.

Param Type Default Description
[list] Array [] Genesis state for the Stack instance.

stack.push(data) ⇒ Number

Push data onto the stack. Changes the Stack#frame and Stack#id.

Kind: instance method of Stack
Returns: Number - Resulting size of the stack.

Param Type Description
data Mixed Treated as a State.

State ⇐ EventEmitter

The State is the core of most User-facing interactions. To interact with the User, simply propose a change in the state by committing to the outcome. This workflow keeps app design quite simple!

Kind: global class
Extends: EventEmitter
Properties

Name Type Description
size Number Size of state in bytes.
@buffer Buffer Byte-for-byte memory representation of state.
@type String Named type.
@data Mixed Local instance of the state.
@id String Unique identifier for this data.

new State(data)

Creates a snapshot of some information.

Param Type Description
data Mixed Input data.

state.id : Boolean

Identity function.

Kind: instance property of State

state.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of State
Returns: String - Serialized Blob.

state.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of State
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

state.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of State
Returns: State - [description]

Param Type Description
input String [description]

state.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of State

state.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of State

Param Type Description
path Path Key to retrieve.

state.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of State

Param Type Description
path Path Key to retrieve.

state.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of State

state.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of State
Returns: String - JSON-encoded String.

State.fromJSON(input) ⇒ State

Marshall an input into an instance of a State. States have absolute authority over their own domain, so choose your States wisely.

Kind: static method of State
Returns: State - Resulting instance of the State.

Param Type Description
input String Arbitrary input.

Storage

Persistent data storage.

Kind: global class

new Storage(config)

Param Type Description
config Object Configuration for internal datastore.

Store

Long-term storage.

Kind: global class
Properties

Name Type Description
settings Mixed Current configuration.

new Store([settings])

Create an instance of a Store to manage long-term storage, which is particularly useful when building a user-facing Product.

Param Type Default Description
[settings] Object {} configuration object.

store._REGISTER(obj) ⇒ Vector

Registers an Actor. Necessary to store in a collection.

Kind: instance method of Store
Returns: Vector - Returned from storage.set

Param Type Description
obj Object Instance of the object to store.

store._POST(key, value) ⇒ Promise

Insert something into a collection.

Kind: instance method of Store
Returns: Promise - Resolves on success with a String pointer.

Param Type Description
key String Path to add data to.
value Mixed Object to store.

store.get(key) ⇒ Promise

Barebones getter.

Kind: instance method of Store
Returns: Promise - Resolves on complete. null if not found.

Param Type Description
key String Name of data to retrieve.

store.set(key, value)

Set a key to a specific value.

Kind: instance method of Store

Param Type Description
key String Address of the information.
value Mixed Content to store at key.

store.trust(source) ⇒ Store

Implicitly trust an Event source.

Kind: instance method of Store
Returns: Store - Resulting instance of Store with new trust.

Param Type Description
source EventEmitter Event-emitting source.

store.del(key)

Remove a Value by Path.

Kind: instance method of Store

Param Type Description
key Path Key to remove.

store.flush()

Wipes the storage.

Kind: instance method of Store

store.start() ⇒ Promise

Start running the process.

Kind: instance method of Store
Returns: Promise - Resolves on complete.

Swap : Object

The Swap contract executes a set of transactions on two distinct Chain components, utilizing a secret-reveal mechanism to atomically execute either the full set or none.

Kind: global class

new Swap([settings])

Atomically execute a set of transactions across two Chain components.

Param Type Default Description
[settings] Object {} Configuration for the swap.

swap.extractSecret(tx, address) ⇒ Mixed

Find an input from the provided transaction which spends from the target P2SH address.

Kind: instance method of Swap
Returns: Mixed - False on failure, secret value on success.

Param Type Description
tx Transaction Transaction to iterate over.
address String P2SH address to search for.

Swarm : String

Orchestrates a network of peers.

Kind: global class

new Swarm(config)

Create an instance of a Swarm.

Param Type Description
config Object Configuration object.

swarm.trust(source)

Explicitly trust an EventEmitter to provide messages using the expected Interface, providing Message objects as the expected Type.

Kind: instance method of Swarm

Param Type Description
source EventEmitter Actor to utilize.

swarm.start() ⇒ Promise

Begin computing.

Kind: instance method of Swarm
Returns: Promise - Resolves to instance of Swarm.

Transition

The Transition type reflects a change from one finite State to another.

Kind: global class

new Transition(settings)

Param Type Description
settings Object Configuration for the transition object.

Value

Number-like type.

Kind: global class

new Value(data)

Use the Value type to interact with Number-like objects.

Param Type Description
data Mixed Input value.

value.value(input)

Compute the numeric representation of this input.

Kind: instance method of Value

Param Type Description
input String Input string to seek for value.

Vector

Kind: global class

new Vector(origin)

An "Initialization" Vector.

Param Type Description
origin Object Input state (will map to @data.)

vector._serialize(input) ⇒ String

_serialize is a placeholder, should be discussed.

Kind: instance method of Vector
Returns: String - - resulting string [JSON-encoded version of the local @data value.]

Param Type Description
input String What to serialize. Defaults to this.state.

vector.toString(input) ⇒ String

Render the output to a String.

Kind: instance method of Vector

Param Type Description
input Mixed Arbitrary input.

Walker

Kind: global class

new Walker(init)

The Walker explores a directory tree and maps it to memory.

Param Type Description
init Vector Initial state tree.

walker._explore(path, [map]) ⇒ Object

Explores a directory tree on the local system's disk.

Kind: instance method of Walker
Returns: Object - [description]

Param Type Default Description
path String [description]
[map] Object {} [description]

walker._define(dir, [map]) ⇒ Object

Explores a directory tree on the local system's disk.

Kind: instance method of Walker
Returns: Object - A hashmap of directory contents.

Param Type Default Description
dir String Path to crawl on local disk.
[map] Object {} Pointer to previous step in stack.

Wallet : Object

Manage keys and track their balances.

Kind: global class
Properties

Name Type Description
id String Unique identifier for this Wallet.

new Wallet([settings])

Create an instance of a Wallet.

Param Type Default Description
[settings] Object {} Configure the wallet.
[settings.verbosity] Number 2 One of: 0 (none), 1 (error), 2 (warning), 3 (notice), 4 (debug), 5 (audit)
[settings.key] Object Key to restore from.
[settings.key.seed] String Mnemonic seed for a restored wallet.

wallet.getAddressForScript(script)

Returns a bech32 address for the provided Script.

Kind: instance method of Wallet

Param Type
script Script

wallet.getAddressFromRedeemScript(redeemScript)

Generate a BitcoinAddress for the supplied BitcoinScript.

Kind: instance method of Wallet

Param Type
redeemScript BitcoinScript

wallet.createPricedOrder(order)

Create a priced order.

Kind: instance method of Wallet

Param Type
order Object
order.asset Object
order.amount Object

wallet._sign(tx)

Signs a transaction with the keyring.

Kind: instance method of Wallet

Param Type
tx BcoinTX

wallet._createCrowdfund(fund)

Create a crowdfunding transaction.

Kind: instance method of Wallet

Param Type
fund Object

wallet._getSwapInputScript(redeemScript, secret)

Generate Script for claiming a Swap.

Kind: instance method of Wallet

Param Type
redeemScript *
secret *

wallet._getRefundInputScript(redeemScript)

Generate Script for reclaiming funds commited to a Swap.

Kind: instance method of Wallet

Param Type
redeemScript *

wallet.publicKeyFromString(input)

Create a public key from a string.

Kind: instance method of Wallet

Param Type Description
input String Hex-encoded string to create key from.

wallet._load(settings)

Initialize the wallet, including keys and addresses.

Kind: instance method of Wallet

Param Type
settings Object

wallet.start()

Start the wallet, including listening for transactions.

Kind: instance method of Wallet

Worker

Workers are arbitrary containers for processing data. They can be thought of almost like "threads", as they run asynchronously over the duration of a contract's lifetime as "fulfillment conditions" for its closure.

Kind: global class

new Worker(method)

Param Type Description
method function Pure function.

worker.compute(input) ⇒ String

Handle a task.

Kind: instance method of Worker
Returns: String - Outcome of the requested job.

Param Type Description
input Vector Input vector.

Exchange

Implements a basic Exchange.

Kind: global class

new Exchange(settings)

Create an instance of the Exchange. You may run two instances at once to simulate two-party contracts, or use the Fabric Market to find and trade with real peers.

Param Type Description
settings Object Map of settings to values.
settings.fees Object Map of fee settings (all values in BTC).
settings.fees.minimum Object Minimum fee (satoshis).