4

Question

Is there a tool/API that can calculate the number of steps and max consumed memory units for a Plutus script, given all necessary inputs, e.g. datum, redeemer, and script context?

I could be wrong, but it seems like plutus-core provides an evaluation tool that can probably output something useful. However, I don't know how to use the tool. Any instructions of its usage will be extremely helpful.

Background

I am looking for such tool/API to calculate the min fee required for transactions that consume UTxOs locked in Plutus scripts while not depending on Plutus Application Backend (PAB), because I am building a standalone Python library through which users can write entire off-chain codes in Python. It is fine to have plutus-core in the runtime environment, but it is not ideal if I need to write Haskell code or use PAB to solve this problem.

Related questions

How to calculate fees for Plutus Smart Contract? The answer linked to a fee calculator, but this is not what I am looking for, because the calculator still requires users to provide the number of execution steps and memory units.

How to calculate fees in Plutus It is basically asking the same question, except that usage of PAB is allowed.

2 Answers 2

2

Looks like Ogmios just released a new feature that solves this exact problem. Basically, users can now evaluate a transaction through Ogmios's API EvaluateTx and get accurate execution steps and memory from the response.

1

You can also use the build command in cardano-cli. Specify the --calculate-plutus-script-cost flag and you will get a JSON object formatted as follows:

{ "executionUnits": { "memory": 1700, "steps": 476468 }, "lovelaceCost": 133, "scriptHash": "67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656" }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.