@cardano-ogmios/mdk

Members

(static, constant) exports.Json :object

Properties:
Name Type Description
parse function A drop-in replacement for JSON.parse that handles big numbers.
stringify function A drop-in replacement for JSON.stringify that handles big numbers.
Source:
See:
Type:
  • object

Methods

(static) exports.newRpcRequest(method, paramsopt, idopt) → {string}

Creates an RPC-2.0 payload from a method, optional params and an optional id.
Source:
Parameters:
Name Type Attributes Description
method string
params object <optional>
id any <optional>
Returns:
Type:
string

(async, static) exports.ogmios(callback, connectionStringopt) → {Promise}

Open a connection to Ogmios, and run the provided callback. The websocket is passed as a callback for subsequent operations.
Source:
Parameters:
Name Type Attributes Default Description
callback module:@cardano-ogmios/mdk.application Continuation once the connection has been established.
connectionString string <optional>
"ws://127.0.0.1:1337" Server's connection string, or localhost.
Returns:
Type:
Promise
A promise returning whatever is passed to the `done` callback.
Example
await ogmios((ws, done) => {
  ws.once('message', (data) => {
    done(Json.parse(data).result);
  });

  ws.rpc('queryLedgerState/tip');
});

Type Definitions

application(ws, done)

Source:
Parameters:
Name Type Description
ws OgmiosWebSocket.OgmiosWebSocket An isomorphic WebSocket-like interface connected to a running Ogmios server. In addition to the usual event listeners methods, the object is enhanced with handful of useful methods.
done module:@cardano-ogmios/mdk.done A callback to mark the end of the application, possibly yielding a result.

done(resultopt)

Source:
Parameters:
Name Type Attributes Description
result any <optional>
An optional result returned by the application.