OgmiosEvaluatorSubmitter

Ogmios is a lightweight bridge interface for cardano-node. It offers a WebSockets API that enables local clients to speak Ouroboros' mini-protocols via JSON/RPC.

Ogmios is a lightweight bridge interface for cardano-node. It offers a WebSockets API that enables local clients to speak Ouroboros' mini-protocols via JSON/RPC. Ogmios is a fast and lightweight solution that can be deployed alongside relays to create entry points on the Cardano network for various types of applications. (reference: ogmios.dev)

Get started:

const ogmiosProvider = new OgmiosProvider();

Choose network for this demo:

evaluateTxEvaluator

evaluateTx() accepts an unsigned transaction (unsignedTx) and it evaluates the resources required to execute the transaction. Note that, this is only valid for transaction interacting with redeemer (smart contract). By knowing the budget required, you can use this to adjust the redeemer's budget so you don't spend more than you need to execute transactions for this smart contract.

const unsignedTx = await tx.build();
const evaluateTx = await ogmiosProvider.evaluateTx(unsignedTx);

Example responses from unlocking assets from the always succeed smart contract.

[
  {
    "index": 0,
    "tag": "SPEND",
    "budget": {
      "mem": 1700,
      "steps": 368100
    }
  }
]

With the mem and steps, you can refine the budget for the redeemer. For example:

const redeemer = {
  data: { alternative: 0, fields: [...] },
  budget: {
    mem: 1700,
    steps: 368100,
  },
};
Evaluate Transaction

Unlock an asset from the always succeed to check how much it takes to execute this transaction.

submitTxSubmitter

Submit a serialized transaction to the network.

await ogmiosProvider.submitTx(signedTx)