Class: Actor

(protected) Actor(actoropt) → {Actor}

Generic Fabric Actor.

Constructor

(protected) new Actor(actoropt) → {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!
Parameters:
Name Type Attributes Description
actor Object <optional>
Object to use as the actor.
Properties
Name Type Attributes Description
seed String <optional>
BIP24 Mnemonic to use as a seed phrase.
public Buffer <optional>
Public key.
private Buffer <optional>
Private key.
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)).
Source:
Fires:
  • event:message Fabric Message objects.
Returns:
Instance of the Actor. Call Actor#sign to emit a Signature.
Type
Actor

Methods

_readObject(input) → {Object}

Parse an Object into a corresponding Fabric state.
Parameters:
Name Type Description
input Object Object to read as input.
Source:
Returns:
Fabric state.
Type
Object

adopt(changes) → {Actor}

Explicitly adopt a set of JSONPatch-encoded changes.
Parameters:
Name Type Description
changes Array List of JSONPatch operations to apply.
Source:
Returns:
Instance of the Actor.
Type
Actor

commit() → {String}

Resolve the current state to a commitment.
Source:
Returns:
32-byte ID
Type
String

export() → {Object}

Export the Actor's state to a standard Object.
Source:
Returns:
Standard object.
Type
Object

get(path) → {Object}

Retrieve a value from the Actor's state by JSONPointer path.
Parameters:
Name Type Description
path String Path to retrieve using JSONPointer.
Source:
Returns:
Value of the path in the Actor's state.
Type
Object

pause() → {Actor}

Toggles `status` property to paused.
Source:
Returns:
Instance of the Actor.
Type
Actor

serialize() → {String}

Serialize the Actor's current state into a JSON-formatted string.
Source:
Returns:
Type
String

set(path, value) → {Object}

Set a value in the Actor's state by JSONPointer path.
Parameters:
Name Type Description
path String Path to set using JSONPointer.
value Object Value to set.
Source:
Returns:
Value of the path in the Actor's state.
Type
Object

sign() → {Actor}

Signs the Actor.
Source:
Returns:
Type
Actor

toBuffer() → {Buffer}

Casts the Actor to a normalized Buffer.
Source:
Returns:
Type
Buffer

toGenericMessage() → {Object}

Casts the Actor to a generic message.
Source:
Returns:
Generic message object.
Type
Object

toObject() → {Object}

Returns the Actor's current state as an Object.
Source:
Returns:
Type
Object

unpause() → {Actor}

Toggles `status` property to unpaused.
Source:
Returns:
Instance of the Actor.
Type
Actor

value(formatopt) → {Object}

Get the inner value of the Actor with an optional cast type.
Parameters:
Name Type Attributes Default Description
format String <optional>
object Cast the value to one of: `buffer, hex, json, string`
Source:
Returns:
Inner value of the Actor as an Object, or cast to the requested `format`.
Type
Object

(static) fromAny(input) → {Actor}

Create an Actor from a variety of formats.
Parameters:
Name Type Description
input Object Target Object to create.
Source:
Returns:
Instance of the Actor.
Type
Actor

(static) randomBytes(countopt) → {Buffer}

Get a number of random bytes from the runtime environment.
Parameters:
Name Type Attributes Default Description
count Number <optional>
32 Number of random bytes to retrieve.
Source:
Returns:
The random bytes.
Type
Buffer