<p>Looks like Ogmios just released a <a href="https://ogmios.dev/mini-protocols/local-tx-submission/#evaluatetx" rel="nofollow noreferrer">new feature</a> that solves this exact problem. Basically, users can now evaluate a transaction through Ogmios's API <code>EvaluateTx</code> and get accurate execution steps and memory from the response.</p>

CC BY-SA 4.0
2022-02-15T20:58:11.083Z
2022-02-15T20:58:11.083Z
Jerry
<p>You can also use the <code>build</code> command in <code>cardano-cli</code>. Specify the <code>--calculate-plutus-script-cost</code> flag and you will get a JSON object formatted as follows:</p>
<p>{
&quot;executionUnits&quot;: {
&quot;memory&quot;: 1700,
&quot;steps&quot;: 476468
},
&quot;lovelaceCost&quot;: 133,
&quot;scriptHash&quot;: &quot;67f33146617a5e61936081db3b2117cbf59bd2123748f58ac9678656&quot;
}</p>

CC BY-SA 4.0
2022-09-12T10:19:00.887Z
2022-09-12T10:19:00.887Z
Jim
<p><strong>Question</strong></p>
<p>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?</p>
<p>I could be wrong, but it seems like plutus-core provides an <a href="https://github.com/input-output-hk/plutus/tree/master/plutus-core#evaluation" rel="nofollow noreferrer">evaluation tool</a> 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.</p>
<p><strong>Background</strong></p>
<p>I am looking for such tool/API to calculate the min fee required for transactions that consume UTxOs locked in Plutus scripts while <strong>not</strong> depending on Plutus Application Backend (PAB), because I am building a standalone <a href="https://github.com/cffls/pycardano" rel="nofollow noreferrer">Python library</a> 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.</p>
<p><strong>Related questions</strong></p>
<p><a href="https://cardano.stackexchange.com/questions/4883/how-to-calculate-fees-for-plutus-smart-contract">How to calculate fees for Plutus Smart Contract?</a>  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.</p>
<p><a href="https://cardano.stackexchange.com/questions/7066/how-to-calculate-fees-in-plutus">How to calculate fees in Plutus</a> It is basically asking the same question, except that usage of PAB is allowed.</p>

<plutus><smart-contract><fee>
How to estimate execution steps and memory units for a Plutus script?
# How to estimate execution steps and memory units for a Plutus script?

(Asked by: username_0 on 2022-02-07)

**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](https://github.com/input-output-hk/plutus/tree/master/plutus-core#evaluation) 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](https://github.com/cffls/pycardano) 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?](https://cardano.stackexchange.com/questions/4883/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](https://cardano.stackexchange.com/questions/7066/how-to-calculate-fees-in-plutus) It is basically asking the same question, except that usage of PAB is allowed.

**Tags:** plutus, smart-contract, fee

---

## 2 answers

### Answer by username_0 on 2022-02-15. Score: 2 | Accepted answer

Looks like Ogmios just released a [new feature](https://ogmios.dev/mini-protocols/local-tx-submission/#evaluatetx) 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.


---

### Answer by username_1 on 2022-09-12. Score: 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"
}


---

