For the complete documentation index, see llms.txt. This page is also available as Markdown.

evaluateTransaction - Cardano

Example code for the evaluateTransaction JSON-RPC method. Complete guide on how to use evaluateTransaction JSON-RPC in GetBlock Web3 documentation.

This method evaluates the execution units required by the Plutus scripts in a transaction, without submitting it. It returns the memory and CPU budget each script requires.

Parameters

Parameter
Type
Required
Description

transaction

object

Yes

Object with a cbor field holding the base16 transaction

additionalUtxo

array

No

Extra UTXOs to resolve inputs not yet on-chain

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "evaluateTransaction",
    "params": {
        "transaction": {
            "cbor": "84a300818258200e...transaction-cbor-hex...ff"
        },
        "additionalUtxo": []
    },
    "id": "getblock.io"
}'
example.js
const response = await fetch(
    'https://go.getblock.io/<ACCESS-TOKEN>/',
    {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({"jsonrpc": "2.0", "method": "evaluateTransaction", "params": {"transaction": {"cbor": "84a300818258200e...transaction-cbor-hex...ff"}, "additionalUtxo": []}, "id": "getblock.io"})
    }
);
console.log(await response.json());

Response

Response Parameters

Field
Type
Description

validator

object

The redeemer's index and purpose

budget

object

Required memory and CPU execution units

Use Cases

  • Script Budgeting: Measure execution units before submitting

  • Fee Estimation: Price script execution into the transaction fee

  • dApp Testing: Validate that scripts stay within limits

  • Transaction Building: Set redeemer budgets from measured units

Error Handling

Error Code
Message
Description

-32602

Invalid params

The transaction CBOR is missing or malformed

3010

Cannot create evaluation context

The additional UTXO set could not be resolved

3011

Script execution failure

One or more scripts failed during evaluation

-32603

Internal error

The node failed to evaluate the transaction

Was this helpful?