- Actor
Generic Fabric Actor.
- Aggregator
Aggregates a set of balances (inputs).
- App ⇐
Service
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.
- Environment
Interact with the user's Environment.
- Fabric
Reliable decentralized infrastructure.
- Federation
Create and manage sets of signers with the Federation class.
- Filesystem
Interact with a local filesystem.
- 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.
- Identity
Manage a network identity.
- 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.
- Key
Represents a cryptographic key.
- Keystore
Provides an encrypted datastore for generic object storage.
- Ledger ⇐
Scribe
An ordered stack of pages.
- Logger ⇐
Actor
A basic logger that writes logs to the local file system
- 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.
- Node
Full definition of a Fabric node.
- Oracle ⇐
Store
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.
- Reader
Read from a byte stream, seeking valid Fabric messages.
- Remote :
Remote
Interact with a remote Resource. This is currently the only HTTP-related code that should remain in @fabric/core — all else must be moved to @fabric/http before final release!
- Resource
Generic interface for collections of digital objects.
- Router ⇐
Scribe
Process incoming messages.
- Scribe ⇐
State
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
andsend
are the highest-priority jobs, and by default thefabric
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.
- Signer ⇐
Actor
Generic Fabric Signer.
- Snapshot
A type of message to be expected from a Service.
- Stack
Manage stacks of data.
- 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!
- 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.
- Token
Implements a capability-based security token.
- Transition
The Transition type reflects a change from one finite State to another.
- Tree
Class implementing a Merkle Tree.
- 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.
- Bitcoin ⇐
Service
Manages interaction with the Bitcoin network.
- Exchange
Implements a basic Exchange.
- Lightning
Manage a Lightning node.
- Redis
Connect and subscribe to ZeroMQ servers.
- ZMQ
Connect and subscribe to ZeroMQ publishers.
HTTPServerDeprecated 2021-10-16.
ScribeDeprecated 2021-11-06.
StashDeprecated 2021-11-06.
Generic Fabric Actor.
Kind: global class
Emits: event:message Fabric {@link Message} objects.
Access: protected
Properties
Name | Type | Description |
---|---|---|
id | String |
Unique identifier for this Actor (id === SHA256(preimage)). |
preimage | String |
Input hash for the id property (preimage === SHA256(ActorState)). |
- Actor
- new Actor([actor])
- instance
- .adopt(changes) ⇒
Actor
- .commit() ⇒
String
- .export() ⇒
Object
- .get(path) ⇒
Object
- .set(path, value) ⇒
Object
- .toBuffer() ⇒
Buffer
- .toGenericMessage() ⇒
Object
- .toObject() ⇒
Object
- .pause() ⇒
Actor
- .serialize() ⇒
String
- .sign() ⇒
Actor
- .unpause() ⇒
Actor
- .value([format]) ⇒
Object
- ._readObject(input) ⇒
Object
- .adopt(changes) ⇒
- static
- .fromAny(input) ⇒
Actor
- .randomBytes([count]) ⇒
Buffer
- .fromAny(input) ⇒
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!
Returns: Actor
- Instance of the Actor. Call sign to emit a Signature.
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.adopt(changes) ⇒ Actor
Explicitly adopt a set of JSONPatch-encoded changes.
Kind: instance method of Actor
Returns: Actor
- Instance of the Actor.
Param | Type | Description |
---|---|---|
changes | Array |
List of JSONPatch operations to apply. |
Resolve the current state to a commitment.
Kind: instance method of Actor
Returns: String
- 32-byte ID
Export the Actor's state to a standard Object.
Kind: instance method of Actor
Returns: Object
- Standard object.
Retrieve a value from the Actor's state by JSONPointer path.
Kind: instance method of Actor
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to retrieve using JSONPointer. |
Set a value in the Actor's state by JSONPointer path.
Kind: instance method of Actor
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to set using JSONPointer. |
value | Object |
Value to set. |
Casts the Actor to a normalized Buffer.
Kind: instance method of Actor
Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:
preimage
: JSON.stringify(state)hash
: SHA256(preimage)type
: 'FabricActorState'version
: 1 (for now)object
: stateparent
: null (for now)
Kind: instance method of Actor
Returns: Object
- Generic message object.
See
Returns the Actor's current state as an Object.
Kind: instance method of Actor
actor.pause() ⇒ Actor
Toggles status
property to paused.
Kind: instance method of Actor
Returns: Actor
- Instance of the Actor.
Serialize the Actor's current state into a JSON-formatted string.
Kind: instance method of Actor
actor.sign() ⇒ Actor
Signs the Actor.
Kind: instance method of Actor
actor.unpause() ⇒ Actor
Toggles status
property to unpaused.
Kind: instance method of Actor
Returns: Actor
- Instance of the Actor.
Get the inner value of the Actor with an optional cast type.
Kind: instance method of Actor
Returns: Object
- Inner value of the Actor as an Object, or cast to the requested format
.
Param | Type | Default | Description |
---|---|---|---|
[format] | String |
object |
Cast the value to one of: buffer, hex, json, string |
Parse an Object into a corresponding Fabric state.
Kind: instance method of Actor
Returns: Object
- Fabric state.
Param | Type | Description |
---|---|---|
input | Object |
Object to read as input. |
Actor.fromAny(input) ⇒ Actor
Create an Actor from a variety of formats.
Kind: static method of Actor
Returns: Actor
- Instance of the Actor.
Param | Type | Description |
---|---|---|
input | Object |
Target Object to create. |
Get a number of random bytes from the runtime environment.
Kind: static method of Actor
Returns: Buffer
- The random bytes.
Param | Type | Default | Description |
---|---|---|---|
[count] | Number |
32 |
Number of random bytes to retrieve. |
Aggregates a set of balances (inputs).
Kind: global class
- Aggregator
- new Aggregator([settings])
- ._importBalances(list) ⇒
AnchorBalance
- ._computeBalances() ⇒
AnchorBalance
- .commit() ⇒
AggregatorCommit
- "commit"
Create a new Aggregator.
Returns: Aggregator
- Instance of the Aggregator.
Param | Type | Description |
---|---|---|
[settings] | Object |
Map of configuration values. |
[settings.inputs] | Array |
Array of AnchorBalance instances. |
Import a list of AnchorBalance instances.
Kind: instance method of Aggregator
Returns: AnchorBalance
- Summary of resulting balances.
Param | Type | Description |
---|---|---|
list | Array |
List of inputs to add. |
Updates the state to reflect balances from current inputs.
Kind: instance method of Aggregator
Returns: AnchorBalance
- Summary of balances.
Commits the balance of all input.
Kind: instance method of Aggregator
Returns: AggregatorCommit
- Commit instance.
Emits: commit
Commit event.
Kind: event emitted by Aggregator
Properties
Name | Type | Description |
---|---|---|
root | Uint8Array |
Root of the Tree. |
leaves | Array |
Leaves of the Tree. |
App ⇐ Service
Web-friendly application framework for building single-page applications with Fabric-based networking and storage.
Kind: global class
Extends: Service
Properties
Name | Type | Description |
---|---|---|
components | Collection |
Interface elements. |
stash | Store |
Routable Datastore. |
- App ⇐
Service
- new App(definition)
- .start() ⇒
Promise
- .stop() ⇒
Promise
- .define(name, structure) ⇒
Object
- .defer(authority) ⇒
App
- .attach(element) ⇒
App
- .consume(resources) ⇒
App
- .envelop(selector) ⇒
App
- .use(name, definition) ⇒
App
- .render() ⇒
String
- ._registerService(name, Service) ⇒
Service
- .init()
- .tick() ⇒
Number
- .beat() ⇒
Service
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .trust(source) ⇒
Service
- .handler(message) ⇒
Service
- .lock([duration]) ⇒
Boolean
- .route(msg) ⇒
Promise
- ._GET(path) ⇒
Promise
- ._PUT(path, value, [commit]) ⇒
Promise
- .connect(notify) ⇒
Promise
- .send(channel, message) ⇒
Service
- ._registerActor(actor) ⇒
Promise
- ._send(message)
Generic bundle for building Fabric applications.
Returns: App
- Returns an instance of App
.
Param | Type | Description |
---|---|---|
definition | Object |
Application definition. See config for examples. |
Start the program.
Kind: instance method of App
Overrides: start
Stop the program.
Kind: instance method of App
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. |
Get the output of our program.
Kind: instance method of App
Returns: String
- Output of the program.
app._registerService(name, Service) ⇒ Service
Registers a named Service with the application. Services are standardized interfaces for Fabric contracts, emitting Message events with a predictable lifecycle.
Kind: instance method of App
Returns: Service
- The registered service instance.
Internal:
Param | Type | Description |
---|---|---|
name | String |
Internal name of the service. |
Service | Class |
The ES6 class definition implementing Service. |
Called by Web Components. TODO: move to @fabric/http/types/spa
Kind: instance method of App
Overrides: init
Move forward one clock cycle.
Kind: instance method of App
Overrides: tick
app.beat() ⇒ Service
Compute latest state.
Kind: instance method of App
Overrides: beat
Emits: Message#event:beat
Retrieve a key from the State.
Kind: instance method of App
Overrides: get
Returns: Mixed
- Returns the target value if found, otherwise null.
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of App
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
app.trust(source) ⇒ Service
Explicitly trust all events from a known source.
Kind: instance method of App
Overrides: trust
Returns: Service
- Instance of Service after binding events.
Param | Type | Description |
---|---|---|
source | EventEmitter |
Emitter of events. |
app.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 App
Overrides: handler
Returns: Service
- Chainable method.
Param | Type | Description |
---|---|---|
message | Activity |
Message object. |
Attempt to acquire a lock for duration
seconds.
Kind: instance method of App
Overrides: lock
Returns: Boolean
- true if locked, false if unable to lock.
Param | Type | Default | Description |
---|---|---|---|
[duration] | Number |
1000 |
Number of milliseconds to hold lock. |
Resolve a State from a particular Message object.
Kind: instance method of App
Overrides: route
Returns: Promise
- Resolves with resulting State.
Param | Type | Description |
---|---|---|
msg | Message |
Explicit Fabric Message. |
Retrieve a value from the Service's state.
Kind: instance method of App
Overrides: _GET
Returns: Promise
- Resolves with the result.
Param | Type | Description |
---|---|---|
path | String |
Path of the value to retrieve. |
Store a value in the Service's state.
Kind: instance method of App
Overrides: _PUT
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. |
Attach to network.
Kind: instance method of App
Overrides: connect
Returns: Promise
- Resolves to Fabric.
Param | Type | Default | Description |
---|---|---|---|
notify | Boolean |
true |
Commit to changes. |
app.send(channel, message) ⇒ Service
Send a message to a channel.
Kind: instance method of App
Overrides: send
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. |
Register an Actor with the Service.
Kind: instance method of App
Overrides: _registerActor
Returns: Promise
- Resolves upon successful registration.
Param | Type | Description |
---|---|---|
actor | Object |
Instance of the Actor. |
Sends a message.
Kind: instance method of App
Overrides: _send
Param | Type | Description |
---|---|---|
message | Mixed |
Message to send. |
Chain.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
name | String |
Current name. |
indices | Map |
|
storage | Storage |
Holds an immutable chain of events.
Param | Type | Description |
---|---|---|
genesis | Vector |
Initial state for the chain of events. |
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
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. |
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. |
Fund the channel.
Kind: instance method of Channel
Param | Type | Description |
---|---|---|
input | Mixed |
Instance of a Transaction. |
Kind: instance method of Channel
Param | Type | Description |
---|---|---|
channel | Object |
Channel settings. |
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.
Provides a Command Line Interface (CLI) for interacting with the Fabric network using a terminal emulator.
Kind: global class
Create a terminal-based interface for a User.
Param | Type | Description |
---|---|---|
[settings] | Object |
Configuration values. |
[settings.currencies] | Array |
List of currencies to support. |
Starts (and renders) the CLI.
Kind: instance method of CLI
Disconnect all interfaces and exit the process.
Kind: instance method of CLI
Creates a token for the target signer with a provided role and some optional data.
Kind: instance method of CLI
Param | Type | Description |
---|---|---|
params | Array |
Parameters array. |
The Collection type maintains an ordered list of State items.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
@entity | Object |
Fabric-bound entity object. |
- Collection
- new Collection([configuration])
- .asMerkleTree() ⇒
MerkleTree
- ._setKey(name)
- .getByID(id)
- .getLatest()
- .findByField(name, value)
- .findByName(name)
- .findBySymbol(symbol)
- ._patchTarget(path, patches)
- .push(data) ⇒
Number
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
.list() ⇒Array
- .toTypedArray()
- .map() ⇒
Array
- .create(entity) ⇒
Promise
- .import(state, commit)
Create a list of Entity-like objects for later retrieval.
Returns: Collection
- Configured instance of the the Collection.
Param | Type | Default | Description |
---|---|---|---|
[configuration] | Object |
{} |
Configuration object. |
Current elements of the collection as a MerkleTree.
Kind: instance method of Collection
Sets the key
property of collection settings.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
name | String |
Value to set the key setting to. |
Retrieve an element from the collection by ID.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
id | String |
Document identifier. |
Retrieve the most recent element in the collection.
Kind: instance method of Collection
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. |
Find a document by the "name" field.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
name | String |
Name to search for. |
Find a document by the "symbol" field.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
symbol | String |
Value to search for. |
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. |
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. |
Retrieve a key from the State.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Collection
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Deprecated
Generate a list of elements in the collection.
Kind: instance method of Collection
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
Generate a hashtable of elements in the collection.
Kind: instance method of Collection
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. |
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. |
- Compiler :
Actor
- new Compiler(settings)
- instance
- static
Create a new Compiler.
Returns: Compiler
- Instance of the compiler.
Param | Type | Default | Description |
---|---|---|---|
settings | Object |
{} |
Configuration. |
settings.body | Buffer |
Body of the input program to compile. |
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. |
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. |
Provides various network-specific rules.
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. |
Live instance of an ARC in Fabric.
Kind: global class
- Entity :
Object
- new Entity([data])
- .toJSON() ⇒
String
- .toRaw() ⇒
Buffer
- ._downsample([input])
Generic template for virtual objects.
Returns: Entity
- Instance of the Entity.
Param | Type | Default | Description |
---|---|---|---|
[data] | Object |
{} |
Pass an object to use. |
Produces a string of JSON, representing the entity.
Kind: instance method of Entity
Returns: String
- JSON-encoded object.
As a Buffer.
Kind: instance method of Entity
Returns: Buffer
- Slice of memory.
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. |
Interact with the user's Environment.
Kind: global class
Create an instance of Environment.
Returns: Environment
- Instance of the Environment.
Param | Type | Description |
---|---|---|
[settings] | Object |
Settings for the Fabric environment. |
Read a variable from the environment.
Kind: instance method of Environment
Returns: String
- Value of the variable (or an empty string).
Param | Type | Description |
---|---|---|
name | String |
Variable name to read. |
environment.setWallet(wallet, force) ⇒ Environment
Configure the Environment to use a Fabric Wallet.
Kind: instance method of Environment
Returns: Environment
- The Fabric Environment.
Param | Type | Default | Description |
---|---|---|---|
wallet | Wallet |
Wallet to attach. | |
force | Boolean |
false |
Force existing wallets to be destroyed. |
environment.start() ⇒ Environment
Start the Environment.
Kind: instance method of Environment
Returns: Environment
- The Fabric Environment.
Reliable decentralized infrastructure.
Kind: global class
Emits: Fabric#event:thread
, Fabric#event:step Emitted on a `compute` step.
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. |
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.
Create and manage sets of signers with the Federation class.
Kind: global class
Create an instance of a federation.
Returns: Federation
- Instance of the federation.
Param | Type | Description |
---|---|---|
[settings] | Object |
Settings. |
federation.start() ⇒ Federation
Start tracking state (i.e., ready to receive events).
Kind: instance method of Federation
Returns: Federation
- Instance of the Federation.
Interact with a local filesystem.
Kind: global class
- Filesystem
- new Filesystem([settings])
- .ls() ⇒
Array
- .readFile(name) ⇒
Buffer
- .writeFile(name, content) ⇒
Boolean
- ._loadFromDisk() ⇒
Promise
- .sync() ⇒
Filesystem
Synchronize an Actor with a local filesystem.
Returns: Filesystem
- Instance of the Fabric filesystem.
Param | Type | Description |
---|---|---|
[settings] | Object |
Configuration for the Fabric filesystem. |
[settings.path] | Object |
Path of the local filesystem. |
Get the list of files.
Kind: instance method of Filesystem
Returns: Array
- List of files.
Read a file by name.
Kind: instance method of Filesystem
Returns: Buffer
- Contents of the file.
Param | Type | Description |
---|---|---|
name | String |
Name of the file to read. |
Write a file by name.
Kind: instance method of Filesystem
Returns: Boolean
- true
if the write succeeded, false
if it did not.
Param | Type | Description |
---|---|---|
name | String |
Name of the file to write. |
content | Buffer |
Content of the file. |
Load Filesystem state from disk.
Kind: instance method of Filesystem
Returns: Promise
- Resolves with Filesystem instance.
filesystem.sync() ⇒ Filesystem
Syncronize state from the local filesystem.
Kind: instance method of Filesystem
Returns: Filesystem
- Instance of the Fabric filesystem.
Simple interaction with 256-bit spaces.
Kind: global class
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. |
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. |
Reverses the bytes of the digest.
Kind: static method of Hash256
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
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). |
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. |
Manage a network identity.
Kind: global class
- Identity
- new Identity([settings])
- .sign(data) ⇒
Signature
- .toString() ⇒
String
Create an instance of an Identity.
Returns: Identity
- Instance of the identity.
Param | Type | Default | Description |
---|---|---|---|
[settings] | Object |
Settings for the Identity. | |
[settings.seed] | String |
BIP 39 seed phrase. | |
[settings.xprv] | String |
Serialized BIP 32 master private key. | |
[settings.xpub] | String |
Serialized BIP 32 master public key. | |
[settings.account] | Number |
0 |
BIP 44 account index. |
[settings.index] | Number |
0 |
BIP 44 key index. |
Sign a buffer of data using BIP 340: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
Kind: instance method of Identity
Returns: Signature
- Resulting signature (64 bytes).
Param | Type | Description |
---|---|---|
data | Buffer |
Buffer of data to sign. |
Retrieve the bech32m-encoded identity.
Kind: instance method of Identity
Returns: String
- Public identity.
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. |
- Interface ⇐
EventEmitter
Define an Interface by creating an instance of this class.
Returns: Interface
- Instance of the Interface.
Param | Type | Description |
---|---|---|
settings | Object |
Configuration values. |
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. |
Returns current timestamp.
Kind: instance method of Interface
Start the Interface.
Kind: instance method of Interface
Stop the Interface.
Kind: instance method of Interface
Ticks the clock with a named Cycle.
Kind: instance method of Interface
Param | Type | Description |
---|---|---|
val | String |
Name of cycle to scribe. |
Represents a cryptographic key.
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 | Default | 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. | |
[settings.purpose] | String |
44 |
Constrains derivations to this space. |
Provides an encrypted datastore for generic object storage.
Kind: global class
Create an instance of the Store.
Returns: Keystore
- Instance of the store.
Param | Type | Default | Description |
---|---|---|---|
[configuration] | FabricStoreConfiguration |
Settings to use. | |
[configuration.name] | String |
"DefaultStore" |
Name of the Store. |
keystore._setState(state) ⇒ Actor
Saves an Object to the store.
Kind: instance method of Keystore
Returns: Actor
- The local instance of the provided State's Actor.
Param | Type | Description |
---|---|---|
state | Object |
State to store. |
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 ⇐
Scribe
- .append(item) ⇒
Promise
- .now() ⇒
Number
- .trust(source) ⇒
Scribe
- .inherits(scribe) ⇒
Scribe
- .toHTML()
- .toString() ⇒
String
- .serialize([input]) ⇒
Buffer
- .deserialize(input) ⇒
State
- .fork() ⇒
State
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .commit()
- .render() ⇒
String
- .append(item) ⇒
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. |
Retrives the current timestamp, in milliseconds.
Kind: instance method of Ledger
Overrides: now
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
Overrides: trust
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
Overrides: inherits
Returns: Scribe
- The configured instance of the Scribe.
Param | Type | Description |
---|---|---|
scribe | Scribe |
Instance of Scribe to use as parent. |
Converts the State to an HTML document.
Kind: instance method of Ledger
Overrides: toHTML
Unmarshall an existing state to an instance of a Blob.
Kind: instance method of Ledger
Overrides: toString
Returns: String
- Serialized Blob.
Convert to Buffer.
Kind: instance method of Ledger
Overrides: serialize
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
Overrides: deserialize
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
Overrides: fork
Retrieve a key from the State.
Kind: instance method of Ledger
Overrides: get
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Ledger
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Increment the vector clock, broadcast all changes as a transaction.
Kind: instance method of Ledger
Overrides: commit
Compose a JSON string for network consumption.
Kind: instance method of Ledger
Overrides: render
Returns: String
- JSON-encoded String.
Logger ⇐ Actor
A basic logger that writes logs to the local file system
Kind: global class
Extends: Actor
- Logger ⇐
Actor
- .path ⇒
String
- .log(msg) ⇒
Boolean
- .start() ⇒
Promise
- .stop() ⇒
Promise
- .adopt(changes) ⇒
Actor
- .commit() ⇒
String
- .export() ⇒
Object
- .get(path) ⇒
Object
- .set(path, value) ⇒
Object
- .toBuffer() ⇒
Buffer
- .toGenericMessage() ⇒
Object
- .toObject() ⇒
Object
- .pause() ⇒
Actor
- .serialize() ⇒
String
- .sign() ⇒
Actor
- .unpause() ⇒
Actor
- .value([format]) ⇒
Object
- ._readObject(input) ⇒
Object
- .path ⇒
Returns the path to the log file
Kind: instance property of Logger
Writes the specified log to the log file
Kind: instance method of Logger
Returns: Boolean
- true, if msg was successfully written; false otherwise
Param | Type | Description |
---|---|---|
msg | String | Object |
The message to log |
Starts the logger
This method creates the required directories for writing the log file.
Kind: instance method of Logger
Stops the logger
This method closes the log file and returns after it has been closed. Any errors on close would cause the return promise to be rejected.
Kind: instance method of Logger
logger.adopt(changes) ⇒ Actor
Explicitly adopt a set of JSONPatch-encoded changes.
Kind: instance method of Logger
Overrides: adopt
Returns: Actor
- Instance of the Actor.
Param | Type | Description |
---|---|---|
changes | Array |
List of JSONPatch operations to apply. |
Resolve the current state to a commitment.
Kind: instance method of Logger
Overrides: commit
Returns: String
- 32-byte ID
Export the Actor's state to a standard Object.
Kind: instance method of Logger
Overrides: export
Returns: Object
- Standard object.
Retrieve a value from the Actor's state by JSONPointer path.
Kind: instance method of Logger
Overrides: get
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to retrieve using JSONPointer. |
Set a value in the Actor's state by JSONPointer path.
Kind: instance method of Logger
Overrides: set
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to set using JSONPointer. |
value | Object |
Value to set. |
Casts the Actor to a normalized Buffer.
Kind: instance method of Logger
Overrides: toBuffer
Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:
preimage
: JSON.stringify(state)hash
: SHA256(preimage)type
: 'FabricActorState'version
: 1 (for now)object
: stateparent
: null (for now)
Kind: instance method of Logger
Overrides: toGenericMessage
Returns: Object
- Generic message object.
See
Returns the Actor's current state as an Object.
Kind: instance method of Logger
Overrides: toObject
logger.pause() ⇒ Actor
Toggles status
property to paused.
Kind: instance method of Logger
Overrides: pause
Returns: Actor
- Instance of the Actor.
Serialize the Actor's current state into a JSON-formatted string.
Kind: instance method of Logger
Overrides: serialize
logger.sign() ⇒ Actor
Signs the Actor.
Kind: instance method of Logger
Overrides: sign
logger.unpause() ⇒ Actor
Toggles status
property to unpaused.
Kind: instance method of Logger
Overrides: unpause
Returns: Actor
- Instance of the Actor.
Get the inner value of the Actor with an optional cast type.
Kind: instance method of Logger
Overrides: value
Returns: Object
- Inner value of the Actor as an Object, or cast to the requested format
.
Param | Type | Default | Description |
---|---|---|---|
[format] | String |
object |
Cast the value to one of: buffer, hex, json, string |
Parse an Object into a corresponding Fabric state.
Kind: instance method of Logger
Overrides: _readObject
Returns: Object
- Fabric state.
Param | Type | Description |
---|---|---|
input | Object |
Object to read as input. |
General-purpose state machine with Vector-based instructions.
Kind: global class
- Machine
- new Machine(settings)
- .sip([n]) ⇒
Number
- .slurp([n]) ⇒
Number
- .compute(input) ⇒
Machine
Create a Machine.
Param | Type | Description |
---|---|---|
settings | Object |
Run-time configuration. |
Get n
bits of deterministic random data.
Kind: instance method of Machine
Returns: Number
- Random bits from Generator.
Param | Type | Default | Description |
---|---|---|---|
[n] | Number |
128 |
Number of bits to retrieve. |
Get n
bytes of deterministic random data.
Kind: instance method of Machine
Returns: Number
- Random bytes from Generator.
Param | Type | Default | Description |
---|---|---|---|
[n] | Number |
32 |
Number of bytes to retrieve. |
machine.compute(input) ⇒ Machine
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
Returns: Machine
- Instance of the resulting machine.
Param | Type | Description |
---|---|---|
input | Object |
Value to pass as input. |
Stores a list of Transaction elements.
Kind: global class
Emits: event:{Message} confirmed Emitted when the Mempool has dropped a transaction.
Creates an instance of a Mempool Service.
Param | Type | Description |
---|---|---|
settings | Object |
Map of settings to utilize. |
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
- Message :
Object
- new Message(message)
- .asRaw() ⇒
Buffer
- .sign() ⇒
Message
- .verify() ⇒
Boolean
- ._setSigner(signer) ⇒
Message
The Message
type is standardized in Fabric as a Array, which can be added to any other vector to compute a resulting state.
Returns: Message
- Instance of the message.
Param | Type | Description |
---|---|---|
message | Object |
Message vector. Will be serialized by Array#_serialize. |
Returns a Buffer of the complete message.
Kind: instance method of Message
Returns: Buffer
- Buffer of the encoded Message.
message.sign() ⇒ Message
Signs the message using the associated signer.
Kind: instance method of Message
Returns: Message
- Signed message.
Verify a message's signature.
Kind: instance method of Message
Returns: Boolean
- true
if the signature is valid, false
if not.
message._setSigner(signer) ⇒ Message
Sets the signer for the message.
Kind: instance method of Message
Returns: Message
- Instance of the Message with associated signer.
Param | Type | Description |
---|---|---|
signer | Signer |
Signer instance. |
Full definition of a Fabric node.
Kind: global class
Manage a Fabric service.
Returns: Node
- Instance of the managed service.
Param | Type | Description |
---|---|---|
settings | Object |
Configuration for the node. |
Explicitly trusts an EventEmitter.
Kind: instance method of Node
Param | Type | Description |
---|---|---|
source | EventEmitter |
Actor to listen to. |
settings | Object | String |
Label for the trusted messages, or a configuration object. |
Oracle ⇐ Store
An Oracle manages one or more collections, using a mempool
for
transitive state.
Kind: global class
Extends: Store
- Oracle ⇐
Store
- new Oracle(initial)
- .broadcast(msg) ⇒
Boolean
- ._REGISTER(obj) ⇒
Vector
- ._POST(key, value) ⇒
Promise
- .get(key) ⇒
Promise
- .set(key, value)
- .trust(source) ⇒
Store
- .del(key)
- .flush()
- .start() ⇒
Promise
Trusted point-of-reference for external services.
Param | Type | Description |
---|---|---|
initial | Object |
Initialization vector. |
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
Overrides: _REGISTER
Returns: Vector
- Returned from storage.set
Param | Type | Description |
---|---|---|
obj | Object |
Instance of the object to store. |
Insert something into a collection.
Kind: instance method of Oracle
Overrides: _POST
Returns: Promise
- Resolves on success with a String pointer.
Param | Type | Description |
---|---|---|
key | String |
Path to add data to. |
value | Mixed |
Object to store. |
Barebones getter.
Kind: instance method of Oracle
Overrides: get
Returns: Promise
- Resolves on complete. null
if not found.
Param | Type | Description |
---|---|---|
key | String |
Name of data to retrieve. |
Set a key
to a specific value
.
Kind: instance method of Oracle
Overrides: set
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
Overrides: trust
Returns: Store
- Resulting instance of Store with new trust.
Param | Type | Description |
---|---|---|
source | EventEmitter |
Event-emitting source. |
Kind: instance method of Oracle
Overrides: del
Param | Type | Description |
---|---|---|
key | Path |
Key to remove. |
Wipes the storage.
Kind: instance method of Oracle
Overrides: flush
Start running the process.
Kind: instance method of Oracle
Overrides: start
Returns: Promise
- Resolves on complete.
A Path is a Fabric-native link to a Document within the network.
Kind: global class
- Path
- new Path(input)
- .isValid() ⇒
Boolean
Create a new Path.
Param | Type | Description |
---|---|---|
input | String | Object |
Named path. |
Kind: instance method of Path
Returns: Boolean
- Whether or not the Path is valid.
An in-memory representation of a node in our network.
Kind: global class
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. |
Deprecated
Kind: instance property of Peer
Write a Buffer to all connected peers.
Kind: instance method of Peer
Param | Type | Description |
---|---|---|
message | Buffer |
Message buffer to send. |
Open a Fabric connection to the target address and initiate the Fabric Protocol.
Kind: instance method of Peer
Param | Type | Description |
---|---|---|
target | String |
Target address. |
peer._fillPeerSlots() ⇒ Peer
Attempt to fill available connection slots with new peers.
Kind: instance method of Peer
Returns: Peer
- Instance of the peer.
peer._handleFabricMessage(buffer) ⇒ Peer
Handle a Fabric Message buffer.
Kind: instance method of Peer
Returns: Peer
- Instance of the Peer.
Param | Type |
---|---|
buffer | Buffer |
Start the Peer.
Kind: instance method of Peer
Stop the peer.
Kind: instance method of Peer
peer.listen() ⇒ Peer
Start listening for connections.
Kind: instance method of Peer
Returns: Peer
- Chainable method.
Read from a byte stream, seeking valid Fabric messages.
Create an instance of a Reader, which can listen to a byte stream for valid Fabric messages.
Param | Type | Description |
---|---|---|
settings | Object |
Settings for the stream. |
Remote : Remote
Interact with a remote Resource. This is currently the only HTTP-related code that should remain in @fabric/core — all else must be moved to @fabric/http before final release!
Kind: global class
Properties
Name | Type |
---|---|
config | Object |
secure | Boolean |
- Remote :
Remote
- new Remote(target)
- .enumerate() ⇒
Configuration
- .request(type, path, [params]) ⇒
FabricHTTPResult
- ._PUT(path, body) ⇒
FabricHTTPResult
|String
- ._GET(path, params) ⇒
FabricHTTPResult
|String
- ._POST(path, params) ⇒
FabricHTTPResult
|String
- ._OPTIONS(path, params) ⇒
Object
- ._PATCH(path, body) ⇒
Object
- ._DELETE(path, params) ⇒
Object
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. |
Enumerate the available Resources on the remote host.
Kind: instance method of Remote
Returns: Configuration
- An object with enumerable key/value pairs for the Application Resource Contract.
Make an HTTP request to the configured authority.
Kind: instance method of Remote
Param | Type | Description |
---|---|---|
type | String |
One of GET , PUT , POST , DELETE , or OPTIONS . |
path | String |
The path to request from the authority. |
[params] | Object |
Options. |
HTTP PUT against the configured Authority.
Kind: instance method of Remote
Returns: FabricHTTPResult
| String
- Result of request.
Param | Type | Description |
---|---|---|
path | String |
HTTP Path to request. |
body | Object |
Map of parameters to supply. |
HTTP GET against the configured Authority.
Kind: instance method of Remote
Returns: FabricHTTPResult
| String
- Result of request.
Param | Type | Description |
---|---|---|
path | String |
HTTP Path to request. |
params | Object |
Map of parameters to supply. |
HTTP POST against the configured Authority.
Kind: instance method of Remote
Returns: FabricHTTPResult
| String
- Result of request.
Param | Type | Description |
---|---|---|
path | String |
HTTP Path to request. |
params | Object |
Map of parameters to supply. |
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. |
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. |
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. |
Generic interface for collections of digital objects.
Kind: global class
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
- Router ⇐
Scribe
- new Router(map)
- .route(msg) ⇒
Array
- .use(plugin, name) ⇒
Router
- .now() ⇒
Number
- .trust(source) ⇒
Scribe
- .inherits(scribe) ⇒
Scribe
- .toHTML()
- .toString() ⇒
String
- .serialize([input]) ⇒
Buffer
- .deserialize(input) ⇒
State
- .fork() ⇒
State
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .commit()
- .render() ⇒
String
Maintains a list of triggers ("commands") and their behaviors.
Param | Type | Description |
---|---|---|
map | Object |
Map of command names => behaviors. |
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. |
Retrives the current timestamp, in milliseconds.
Kind: instance method of Router
Overrides: now
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
Overrides: trust
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
Overrides: inherits
Returns: Scribe
- The configured instance of the Scribe.
Param | Type | Description |
---|---|---|
scribe | Scribe |
Instance of Scribe to use as parent. |
Converts the State to an HTML document.
Kind: instance method of Router
Overrides: toHTML
Unmarshall an existing state to an instance of a Blob.
Kind: instance method of Router
Overrides: toString
Returns: String
- Serialized Blob.
Convert to Buffer.
Kind: instance method of Router
Overrides: serialize
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
Overrides: deserialize
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
Overrides: fork
Retrieve a key from the State.
Kind: instance method of Router
Overrides: get
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Router
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Increment the vector clock, broadcast all changes as a transaction.
Kind: instance method of Router
Overrides: commit
Compose a JSON string for network consumption.
Kind: instance method of Router
Overrides: render
Returns: String
- JSON-encoded String.
Scribe ⇐ State
Simple tag-based recordkeeper.
Kind: global class
Extends: State
Properties
Name | Type | Description |
---|---|---|
config | Object |
Current configuration. |
- Scribe ⇐
State
- new Scribe(config)
- .now() ⇒
Number
- .trust(source) ⇒
Scribe
- .inherits(scribe) ⇒
Scribe
- .toHTML()
- .toString() ⇒
String
- .serialize([input]) ⇒
Buffer
- .deserialize(input) ⇒
State
- .fork() ⇒
State
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .commit()
- .render() ⇒
String
The "Scribe" is a simple tag-based recordkeeper.
Param | Type | Description |
---|---|---|
config | Object |
General configuration object. |
config.verbose | Boolean |
Should the Scribe be noisy? |
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. |
Converts the State to an HTML document.
Kind: instance method of Scribe
Overrides: toHTML
Unmarshall an existing state to an instance of a Blob.
Kind: instance method of Scribe
Overrides: toString
Returns: String
- Serialized Blob.
Convert to Buffer.
Kind: instance method of Scribe
Overrides: serialize
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
Overrides: deserialize
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
Overrides: fork
Retrieve a key from the State.
Kind: instance method of Scribe
Overrides: get
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Scribe
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Increment the vector clock, broadcast all changes as a transaction.
Kind: instance method of Scribe
Overrides: commit
Compose a JSON string for network consumption.
Kind: instance method of Scribe
Overrides: render
Returns: String
- JSON-encoded String.
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. |
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
Access: protected
Properties
Name | Description |
---|---|
map | The "map" is a hashtable of "key" => "value" pairs. |
- Service
- new Service(settings)
- .init()
- .tick() ⇒
Number
- .beat() ⇒
Service
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .trust(source) ⇒
Service
- .handler(message) ⇒
Service
- .lock([duration]) ⇒
Boolean
- .route(msg) ⇒
Promise
- .start()
- ._GET(path) ⇒
Promise
- ._PUT(path, value, [commit]) ⇒
Promise
- .connect(notify) ⇒
Promise
- .send(channel, message) ⇒
Service
- ._registerActor(actor) ⇒
Promise
- ._send(message)
Create an instance of a Service.
Param | Type | Default | Description |
---|---|---|---|
settings | Object |
Configuration for this service. | |
[settings.networking] | Boolean |
true |
Whether or not to connect to the network. |
[settings.@data] | Object |
Internal data to assign. | |
[settings.frequency] | Object |
Interval frequency in hertz. | |
[settings.state] | Object |
Initial state to assign. |
Called by Web Components. TODO: move to @fabric/http/types/spa
Kind: instance method of Service
Move forward one clock cycle.
Kind: instance method of Service
service.beat() ⇒ Service
Compute latest state.
Kind: instance method of Service
Emits: Message#event:beat
Retrieve a key from the State.
Kind: instance method of Service
Returns: Mixed
- Returns the target value if found, otherwise null.
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Service
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
service.trust(source) ⇒ Service
Explicitly trust all events from a known source.
Kind: instance method of Service
Returns: Service
- Instance of Service after binding events.
Param | Type | Description |
---|---|---|
source | EventEmitter |
Emitter of events. |
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. |
Attempt to acquire a lock for duration
seconds.
Kind: instance method of Service
Returns: Boolean
- true if locked, false if unable to lock.
Param | Type | Default | Description |
---|---|---|---|
[duration] | Number |
1000 |
Number of milliseconds to hold lock. |
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. |
Start the service, including the initiation of an outbound connection to any peers designated in the service's configuration.
Kind: instance method of Service
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. |
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. |
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. |
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. |
Sends a message.
Kind: instance method of Service
Param | Type | Description |
---|---|---|
message | Mixed |
Message to send. |
The Session type describes a connection between Peer objects, and includes its own lifecycle.
Kind: global class
Creates a new Session.
Param | Type |
---|---|
settings | Object |
Opens the Session for interaction.
Kind: instance method of Session
Closes the Session, preventing further interaction.
Kind: instance method of Session
Signer ⇐ Actor
Generic Fabric Signer.
Kind: global class
Extends: Actor
Emits: event:message Fabric {@link Message} objects.
Access: protected
Properties
Name | Type | Description |
---|---|---|
id | String |
Unique identifier for this Signer (id === SHA256(preimage)). |
preimage | String |
Input hash for the id property (preimage === SHA256(SignerState)). |
- Signer ⇐
Actor
- new Signer([actor])
- .sign() ⇒
Signer
- .adopt(changes) ⇒
Actor
- .commit() ⇒
String
- .export() ⇒
Object
- .get(path) ⇒
Object
- .set(path, value) ⇒
Object
- .toBuffer() ⇒
Buffer
- .toGenericMessage() ⇒
Object
- .toObject() ⇒
Object
- .pause() ⇒
Actor
- .serialize() ⇒
String
- .unpause() ⇒
Actor
- .value([format]) ⇒
Object
- ._readObject(input) ⇒
Object
Creates an Signer, which emits messages for other Signers to subscribe to. You can supply certain parameters for the actor, including key material [!!!] — be mindful of what you share with others!
Returns: Signer
- Instance of the Signer. Call sign to emit a Signature.
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. |
signer.sign() ⇒ Signer
Signs some data.
Kind: instance method of Signer
Overrides: sign
signer.adopt(changes) ⇒ Actor
Explicitly adopt a set of JSONPatch-encoded changes.
Kind: instance method of Signer
Overrides: adopt
Returns: Actor
- Instance of the Actor.
Param | Type | Description |
---|---|---|
changes | Array |
List of JSONPatch operations to apply. |
Resolve the current state to a commitment.
Kind: instance method of Signer
Overrides: commit
Returns: String
- 32-byte ID
Export the Actor's state to a standard Object.
Kind: instance method of Signer
Overrides: export
Returns: Object
- Standard object.
Retrieve a value from the Actor's state by JSONPointer path.
Kind: instance method of Signer
Overrides: get
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to retrieve using JSONPointer. |
Set a value in the Actor's state by JSONPointer path.
Kind: instance method of Signer
Overrides: set
Returns: Object
- Value of the path in the Actor's state.
Param | Type | Description |
---|---|---|
path | String |
Path to set using JSONPointer. |
value | Object |
Value to set. |
Casts the Actor to a normalized Buffer.
Kind: instance method of Signer
Overrides: toBuffer
Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:
preimage
: JSON.stringify(state)hash
: SHA256(preimage)type
: 'FabricActorState'version
: 1 (for now)object
: stateparent
: null (for now)
Kind: instance method of Signer
Overrides: toGenericMessage
Returns: Object
- Generic message object.
See
Returns the Actor's current state as an Object.
Kind: instance method of Signer
Overrides: toObject
signer.pause() ⇒ Actor
Toggles status
property to paused.
Kind: instance method of Signer
Overrides: pause
Returns: Actor
- Instance of the Actor.
Serialize the Actor's current state into a JSON-formatted string.
Kind: instance method of Signer
Overrides: serialize
signer.unpause() ⇒ Actor
Toggles status
property to unpaused.
Kind: instance method of Signer
Overrides: unpause
Returns: Actor
- Instance of the Actor.
Get the inner value of the Actor with an optional cast type.
Kind: instance method of Signer
Overrides: value
Returns: Object
- Inner value of the Actor as an Object, or cast to the requested format
.
Param | Type | Default | Description |
---|---|---|---|
[format] | String |
object |
Cast the value to one of: buffer, hex, json, string |
Parse an Object into a corresponding Fabric state.
Kind: instance method of Signer
Overrides: _readObject
Returns: Object
- Fabric state.
Param | Type | Description |
---|---|---|
input | Object |
Object to read as input. |
A type of message to be expected from a Service.
Kind: global class
Creates an instance of a Snapshot.
Param | Type | Description |
---|---|---|
settings | Object |
Map of settings to configure the Snapshot with. |
Retrieves the sha256
fingerprint for the Snapshot state.
Kind: instance method of Snapshot
Manage stacks of data.
Kind: global class
- Stack
- new Stack([list])
- .push(data) ⇒
Number
Create a Stack instance.
Returns: Stack
- Instance of the Stack.
Param | Type | Default | Description |
---|---|---|---|
[list] | Array |
[] |
Genesis state for the Stack instance. |
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. |
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
Access: protected
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. |
- State ⇐
EventEmitter
- new State(data)
- instance
- .toHTML()
- .toString() ⇒
String
- .serialize([input]) ⇒
Buffer
- .deserialize(input) ⇒
State
- .fork() ⇒
State
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .commit()
- .render() ⇒
String
- static
Creates a snapshot of some information.
Returns: State
- Resulting state.
Param | Type | Description |
---|---|---|
data | Mixed |
Input data. |
Converts the State to an HTML document.
Kind: instance method of State
Unmarshall an existing state to an instance of a Blob.
Kind: instance method of State
Returns: String
- Serialized Blob.
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
Retrieve a key from the State.
Kind: instance method of State
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of State
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Increment the vector clock, broadcast all changes as a transaction.
Kind: instance method of State
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. |
Long-term storage.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
settings | Mixed |
Current configuration. |
- Store
- new Store([settings])
- ._REGISTER(obj) ⇒
Vector
- ._POST(key, value) ⇒
Promise
- .get(key) ⇒
Promise
- .set(key, value)
- .trust(source) ⇒
Store
- .del(key)
- .flush()
- .start() ⇒
Promise
Create an instance of a Store to manage long-term storage, which is particularly useful when building a user-facing Product.
Returns: Store
- Instance of the Store, ready to start.
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. |
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. |
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. |
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. |
Kind: instance method of Store
Param | Type | Description |
---|---|---|
key | Path |
Key to remove. |
Wipes the storage.
Kind: instance method of Store
Start running the process.
Kind: instance method of Store
Returns: Promise
- Resolves on complete.
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
- Swap :
Object
Atomically execute a set of transactions across two Chain components.
Param | Type | Default | Description |
---|---|---|---|
[settings] | Object |
{} |
Configuration for the swap. |
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. |
Orchestrates a network of peers.
Kind: global class
- Swarm :
String
- new Swarm(config)
- .trust(source)
- .start() ⇒
Promise
Create an instance of a Swarm.
Returns: Swarm
- Instance of the Swarm.
Param | Type | Description |
---|---|---|
config | Object |
Configuration object. |
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. |
Begin computing.
Kind: instance method of Swarm
Returns: Promise
- Resolves to instance of Swarm.
Implements a capability-based security token.
Create a new Fabric Token.
Returns: Token
- The token instance.
Param | Type | Description |
---|---|---|
[settings] | Object |
Configuration. |
The Transition type reflects a change from one finite State to another.
Param | Type | Description |
---|---|---|
settings | Object |
Configuration for the transition object. |
Class implementing a Merkle Tree.
Kind: global class
- Tree
- new Tree([settings])
- .addLeaf(leaf) ⇒
Tree
- .getLeaves() ⇒
Array
Create an instance of a Tree.
Returns: Tree
- Instance of the tree.
Param | Type | Description |
---|---|---|
[settings] | Object |
Configuration. |
tree.addLeaf(leaf) ⇒ Tree
Add a leaf to the tree.
Kind: instance method of Tree
Returns: Tree
- Instance of the tree.
Param | Type | Description |
---|---|---|
leaf | String |
Leaf to add to the tree. |
Get a list of the Tree's leaves.
Kind: instance method of Tree
Returns: Array
- A list of the Tree's leaves.
Number-like type.
Kind: global class
Use the Value type to interact with Number-like objects.
Param | Type | Description |
---|---|---|
data | Mixed |
Input value. |
Compute the numeric representation of this input.
Kind: instance method of Value
Param | Type | Description |
---|---|---|
input | String |
Input string to seek for value. |
Kind: global class
- Vector
- new Vector(origin)
- ._serialize(input) ⇒
String
- .toString(input) ⇒
String
An "Initialization" Vector.
Param | Type | Description |
---|---|---|
origin | Object |
Input state (will map to @data .) |
_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 . |
Render the output to a String.
Kind: instance method of Vector
Param | Type | Description |
---|---|---|
input | Mixed |
Arbitrary input. |
Kind: global class
- Walker
- new Walker(init)
- ._explore(path, [map]) ⇒
Object
- ._define(dir, [map]) ⇒
Object
The Walker explores a directory tree and maps it to memory.
Param | Type | Description |
---|---|---|
init | Vector |
Initial state tree. |
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] |
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. |
Manage keys and track their balances.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
id | String |
Unique identifier for this Wallet. |
- Wallet :
Object
- new Wallet([settings])
- instance
- static
- .createSeed(passphrase) ⇒
FabricSeed
- .fromSeed(seed) ⇒
Wallet
- .createSeed(passphrase) ⇒
Create an instance of a Wallet.
Returns: Wallet
- Instance of the 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.loadKey(keypair) ⇒ Wallet
Import a key to the wallet.
Kind: instance method of Wallet
Returns: Wallet
- Instance of the Wallet.
Param | Type | Description |
---|---|---|
keypair | Object |
Keypair. |
keypair.public | Buffer |
Public key. |
[keypair.private] | Buffer |
Private key. |
Start the wallet, including listening for transactions.
Kind: instance method of Wallet
Initialize the wallet, including keys and addresses.
Kind: instance method of Wallet
Param | Type | Description |
---|---|---|
settings | Object |
Settings to load. |
Returns a bech32 address for the provided Script.
Kind: instance method of Wallet
Param | Type |
---|---|
script | Script |
Generate a BitcoinAddress for the supplied BitcoinScript.
Kind: instance method of Wallet
Param | Type |
---|---|
redeemScript | BitcoinScript |
Create a priced order.
Kind: instance method of Wallet
Param | Type |
---|---|
order | Object |
order.asset | Object |
order.amount | Object |
Signs a transaction with the keyring.
Kind: instance method of Wallet
Param | Type |
---|---|
tx | BcoinTX |
Create a crowdfunding transaction.
Kind: instance method of Wallet
Param | Type |
---|---|
fund | Object |
Generate Script for claiming a Swap.
Kind: instance method of Wallet
Param | Type |
---|---|
redeemScript | * |
secret | * |
Generate Script for reclaiming funds commited to a Swap.
Kind: instance method of Wallet
Param | Type |
---|---|
redeemScript | * |
Create a public key from a string.
Kind: instance method of Wallet
Param | Type | Description |
---|---|---|
input | String |
Hex-encoded string to create key from. |
Create a new seed phrase.
Kind: static method of Wallet
Returns: FabricSeed
- The seed object.
Param | Type | Description |
---|---|---|
passphrase | String |
BIP 39 passphrase for key derivation. |
Wallet.fromSeed(seed) ⇒ Wallet
Create a new Wallet from a seed object.
Kind: static method of Wallet
Returns: Wallet
- Instance of the wallet.
Param | Type | Description |
---|---|---|
seed | FabricSeed |
Fabric seed. |
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
- Worker
- new Worker(method)
- .compute(input) ⇒
String
Param | Type | Description |
---|---|---|
method | function |
Pure function. |
Handle a task.
Kind: instance method of Worker
Returns: String
- Outcome of the requested job.
Param | Type | Description |
---|---|---|
input | Vector |
Input vector. |
Bitcoin ⇐ Service
Manages interaction with the Bitcoin network.
Kind: global class
Extends: Service
- Bitcoin ⇐
Service
- new Bitcoin([settings])
- .UAString
- .tip
- .height
- .broadcast(tx)
- ._processSpendMessage(message) ⇒
BitcoinTransactionID
- ._prepareTransaction(obj)
- ._handleCommittedBlock(block)
- ._handlePeerPacket(msg)
- ._handleBlockFromSPV(msg)
- ._handleTransactionFromSPV(tx)
- ._subscribeToShard(shard)
- ._connectSPV()
- .connect(addr)
- ._requestBlockAtHeight(height) ⇒
Object
- ._createContractProposal(options) ⇒
ContractProposal
- ._buildPSBT(options) ⇒
PSBT
- .start()
- .stop()
- .init()
- .tick() ⇒
Number
- .beat() ⇒
Service
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .trust(source) ⇒
Service
- .handler(message) ⇒
Service
- .lock([duration]) ⇒
Boolean
- .route(msg) ⇒
Promise
- ._GET(path) ⇒
Promise
- ._PUT(path, value, [commit]) ⇒
Promise
- .send(channel, message) ⇒
Service
- ._registerActor(actor) ⇒
Promise
- ._send(message)
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. |
User Agent string for the Bitcoin P2P network.
Kind: instance property of Bitcoin
Chain tip (block hash of the chain with the most Proof of Work)
Kind: instance property of Bitcoin
Chain height (=== length - 1
)
Kind: instance property of Bitcoin
Broadcast a transaction to the Bitcoin network.
Kind: instance method of Bitcoin
Unstable:
Param | Type | Description |
---|---|---|
tx | TX |
Bitcoin transaction |
Process a spend message.
Kind: instance method of Bitcoin
Returns: BitcoinTransactionID
- Hex-encoded representation of the transaction ID.
Param | Type | Description |
---|---|---|
message | SpendMessage |
Generic-level message for spending. |
message.amount | String |
Amount (in BTC) to spend. |
message.destination | String |
Destination for funds. |
Prepares a Transaction for storage.
Kind: instance method of Bitcoin
Param | Type | Description |
---|---|---|
obj | Transaction |
Transaction to prepare. |
Receive a committed block.
Kind: instance method of Bitcoin
Param | Type | Description |
---|---|---|
block | Block |
Block to handle. |
Process a message from a peer in the Bitcoin network.
Kind: instance method of Bitcoin
Param | Type | Description |
---|---|---|
msg | PeerPacket |
Message from peer. |
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. |
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. |
Attach event handlers for a supplied list of addresses.
Kind: instance method of Bitcoin
Param | Type | Description |
---|---|---|
shard | Shard |
List of addresses to monitor. |
Initiate outbound connections to configured SPV nodes.
Kind: instance method of Bitcoin
Connect to a Fabric Peer.
Kind: instance method of Bitcoin
Overrides: connect
Param | Type | Description |
---|---|---|
addr | String |
Address to connect to. |
Retrieve the equivalent to getblockhash
from Bitcoin Core.
Kind: instance method of Bitcoin
Returns: Object
- The block hash.
Param | Type | Description |
---|---|---|
height | Number |
Height of block to retrieve. |
Creates an unsigned Bitcoin transaction.
Kind: instance method of Bitcoin
Returns: ContractProposal
- Instance of the proposal.
Param | Type |
---|---|
options | Object |
Create a Partially-Signed Bitcoin Transaction (PSBT).
Kind: instance method of Bitcoin
Returns: PSBT
- Instance of the PSBT.
Param | Type | Description |
---|---|---|
options | Object |
Parameters for the PSBT. |
Start the Bitcoin service, including the initiation of outbound requests.
Kind: instance method of Bitcoin
Overrides: start
Stop the Bitcoin service.
Kind: instance method of Bitcoin
Called by Web Components. TODO: move to @fabric/http/types/spa
Kind: instance method of Bitcoin
Overrides: init
Move forward one clock cycle.
Kind: instance method of Bitcoin
Overrides: tick
bitcoin.beat() ⇒ Service
Compute latest state.
Kind: instance method of Bitcoin
Overrides: beat
Emits: Message#event:beat
Retrieve a key from the State.
Kind: instance method of Bitcoin
Overrides: get
Returns: Mixed
- Returns the target value if found, otherwise null.
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Bitcoin
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
bitcoin.trust(source) ⇒ Service
Explicitly trust all events from a known source.
Kind: instance method of Bitcoin
Overrides: trust
Returns: Service
- Instance of Service after binding events.
Param | Type | Description |
---|---|---|
source | EventEmitter |
Emitter of events. |
bitcoin.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 Bitcoin
Overrides: handler
Returns: Service
- Chainable method.
Param | Type | Description |
---|---|---|
message | Activity |
Message object. |
Attempt to acquire a lock for duration
seconds.
Kind: instance method of Bitcoin
Overrides: lock
Returns: Boolean
- true if locked, false if unable to lock.
Param | Type | Default | Description |
---|---|---|---|
[duration] | Number |
1000 |
Number of milliseconds to hold lock. |
Resolve a State from a particular Message object.
Kind: instance method of Bitcoin
Overrides: route
Returns: Promise
- Resolves with resulting State.
Param | Type | Description |
---|---|---|
msg | Message |
Explicit Fabric Message. |
Retrieve a value from the Service's state.
Kind: instance method of Bitcoin
Overrides: _GET
Returns: Promise
- Resolves with the result.
Param | Type | Description |
---|---|---|
path | String |
Path of the value to retrieve. |
Store a value in the Service's state.
Kind: instance method of Bitcoin
Overrides: _PUT
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. |
bitcoin.send(channel, message) ⇒ Service
Send a message to a channel.
Kind: instance method of Bitcoin
Overrides: send
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. |
Register an Actor with the Service.
Kind: instance method of Bitcoin
Overrides: _registerActor
Returns: Promise
- Resolves upon successful registration.
Param | Type | Description |
---|---|---|
actor | Object |
Instance of the Actor. |
Sends a message.
Kind: instance method of Bitcoin
Overrides: _send
Param | Type | Description |
---|---|---|
message | Mixed |
Message to send. |
Implements a basic Exchange.
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.
Returns: Exchnge
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). |
Manage a Lightning node.
Kind: global class
- Lightning
- new Lightning([settings])
- ._makeRPCRequest(method, [params]) ⇒
Object
|String
Create an instance of the Lightning Service.
Param | Type | Description |
---|---|---|
[settings] | Object |
Settings. |
Make an RPC request through the Lightning UNIX socket.
Kind: instance method of Lightning
Returns: Object
| String
- Respond from the Lightning node.
Param | Type | Description |
---|---|---|
method | String |
Name of method to call. |
[params] | Array |
Array of parameters. |
Connect and subscribe to ZeroMQ servers.
Kind: global class
Creates an instance of a ZeroMQ subscriber.
Returns: Redis
- Instance of the Redis service, ready to run start()
Param | Type | Description |
---|---|---|
[settings] | Object |
Settings for the Redis connection. |
[settings.host] | String |
Host for the Redis server. |
[settings.port] | Number |
Remote ZeroMQ service port. |
redis.start() ⇒ Redis
Opens the connection and subscribes to the requested channels.
Kind: instance method of Redis
Returns: Redis
- Instance of the service.
redis.stop() ⇒ Redis
Closes the connection to the Redis server.
Kind: instance method of Redis
Returns: Redis
- Instance of the service.
Connect and subscribe to ZeroMQ publishers.
Kind: global class
Creates an instance of a ZeroMQ subscriber.
Returns: ZMQ
- Instance of the ZMQ service, ready to run start()
Param | Type | Description |
---|---|---|
[settings] | Object |
Settings for the ZMQ connection. |
[settings.host] | String |
Host for the ZMQ publisher. |
[settings.port] | Number |
Remote ZeroMQ service port. |
zmQ.start() ⇒ ZMQ
Opens the connection and subscribes to the requested channels.
Kind: instance method of ZMQ
Returns: ZMQ
- Instance of the service.
zmQ.stop() ⇒ ZMQ
Closes the connection to the ZMQ publisher.
Kind: instance method of ZMQ
Returns: ZMQ
- Instance of the service.
Deprecated
Deprecated 2021-10-16.
Deprecated
Deprecated 2021-11-06.
Kind: global class
Scribe- new Scribe(config)
- .now() ⇒
Number
- .trust(source) ⇒
Scribe
- .inherits(scribe) ⇒
Scribe
- .toHTML()
- .toString() ⇒
String
- .serialize([input]) ⇒
Buffer
- .deserialize(input) ⇒
State
- .fork() ⇒
State
- .get(path) ⇒
Mixed
- .set(path) ⇒
Mixed
- .commit()
- .render() ⇒
String
The "Scribe" is a simple tag-based recordkeeper.
Param | Type | Description |
---|---|---|
config | Object |
General configuration object. |
config.verbose | Boolean |
Should the Scribe be noisy? |
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. |
Converts the State to an HTML document.
Kind: instance method of Scribe
Overrides: toHTML
Unmarshall an existing state to an instance of a Blob.
Kind: instance method of Scribe
Overrides: toString
Returns: String
- Serialized Blob.
Convert to Buffer.
Kind: instance method of Scribe
Overrides: serialize
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
Overrides: deserialize
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
Overrides: fork
Retrieve a key from the State.
Kind: instance method of Scribe
Overrides: get
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Set a key in the State to a particular value.
Kind: instance method of Scribe
Overrides: set
Param | Type | Description |
---|---|---|
path | Path |
Key to retrieve. |
Increment the vector clock, broadcast all changes as a transaction.
Kind: instance method of Scribe
Overrides: commit
Compose a JSON string for network consumption.
Kind: instance method of Scribe
Overrides: render
Returns: String
- JSON-encoded String.
Deprecated
Deprecated 2021-11-06.
Kind: global class