OgmiosWebSocket

OgmiosWebSocket

Source:

Methods

(async, generator, static) asyncChainFollower() → {Promise.<(RollForward|RollBackward)>}

Yields roll-forward or roll-backward events from a node. This generator terminates after yielding all the requested blocks (count) or never if following the chain indefinitely.
Source:
See:
Returns:
Type:
Promise.<(RollForward|RollBackward)>

Type Definitions

OgmiosWebSocket

Properties:
Name Type Description
rpc OgmiosWebSocket.rpc Perform an arbitrary rpc query using the given method name and optional parameters.
queryLedgerState OgmiosWebSocket.queryLedgerState A short-hand for running a single ledger-state query.
queryNetwork OgmiosWebSocket.queryNetwork A short-hand for running a single network query.
newChainFollower OgmiosWebSocket.newChainFollower Create a generator for following the chain from any given point.
Mixes In:
  • Websocket
Source:
See:
Type:
  • object

Point

A point on chain.
Properties:
Name Type Description
id string A base-16 encoded header hash.
slot integer An absolute slot number.
Source:
Type:
  • object

newChainFollower(pointsopt, countopt) → {OgmiosWebSocket.asyncChainFollower}

Create a generator of RollForward|RollBackward for following the chain from any given point.
Source:
See:
Parameters:
Name Type Attributes Description
points Array.<(OgmiosWebSocket.Point|"origin")> <optional>
Points to use for intersection in order to negotiate for an intersection.
count integer <optional>
Number of blocks to fetch. If omitted, will run indefinitely.
Examples
const chainFollower = await ws.newChainFollower();

for await (const { block } of chainFollower()) {
  console.log(block);
}
const chainFollower = await ws.newChainFollower(
   [
     {
       id: "3d6f139f9f019668fe0412cacfaeb9e0be42e7b0f6ab21d6bddbc12d771ec18a",
       slot: 86268539,
     },
   ],
   1
 );

 for await (const { block } of chainFollower()) {
   console.log(block);
 }

queryLedgerState(method, paramsopt) → {Promise.<any>}

A short-hand for running a single ledger-state query. If a state has been acquired, then it is ran on that state. If not, it is ran from the most recent ledger state available.
Source:
Parameters:
Name Type Attributes Description
method string The ledger state query name (without "queryLedgerState/").
params object <optional>
Optional parameters for the query, if any.
Returns:
Type:
Promise.<any>
A promise holding the result for that query.
Example
const tip = await ws.queryLedgerState("tip");

queryNetwork(method, paramsopt) → {Promise.<any>}

A short-hand for running a single network query.
Source:
Parameters:
Name Type Attributes Description
method string The ledger state query name (without "queryNetwork/").
params object <optional>
Optional parameters for the query, if any.
Returns:
Type:
Promise.<any>
A promise holding the result for that query.
Example
const startTime = await ws.queryNetwork("startTime");

rpc(method, paramsopt, idopt)

Perform an arbitrary rpc query using the given method name and optional parameters. This supposes that an event listener on `"message"` has been installed.
Source:
See:
Parameters:
Name Type Attributes Description
method string The Ogmios RPC method.
params object <optional>
Optional parameters for the method.
id any <optional>
An optional request id.
Examples
ws.once("message", (data) => { ... });
ws.rpc('findIntersection', { point: [ "origin" ] }, "my-request-id");
ws.once("message", (data) => { ... });
ws.rpc('queryLedgerState/tip');