Cardano’s approach to price setting mainly relies on market demand over actualsupply. On Cardano, more than one type of demand competes for the common supply.Thus, it is crucial to consider both relative and absolute pricing. One wayto do this is to inspect the effects of smart contract pricing, non-fungibletoken (NFT) operations, and so on, with respect to some common value – in ourcase, the consumption of Cardano’s processing power.
The Cardano ledger's design is focused on high assurance, security, and provenformal verification. In alignment with this strategy, it is also important toensure that transaction processing is deterministic, meaning that a user canpredict the impact and outcome of a transaction before its actual execution.
The ability to guarantee the cost of transaction execution and how thetransaction behaves on the ledger before it is submitted became even moreprominent with the introduction of smart contract support in 2021. This featureis different from other blockchains, including Ethereum, where other networkactivity can influence the gas cost. This ability is also guaranteed by thedeterministic nature of Cardano and Plutus scripts.
Determinism
Determinism, in the context of transaction and script processing, is a synonymfor predictability. This means that a user can predict locally (off-chain) howtheir transaction will impact the on-chain state of the ledger, withoutencountering the following:
- unexpected script validation outcomes or failures
- unexpected fees
- unexpected ledger or script state updates.
Validation
An important aspect of processing a transaction is validating the actions it istaking. A transaction is taking an action when it contains data in thespecific field to that action. For example, a transaction is spending UTXO Uwhen it contains a reference to U in its input field, and it is minting atoken X when its mint field contains X.
Cardano uses scripts to validate actions. These scripts, which are pieces ofcode, implement pure functions with True or False outputs. Scriptvalidation is the process of invoking the script interpreter to run a givenscript on appropriate arguments.
Script validation can be performed for the following actions:
- Spending a UTXO locked by a script address: the script that is run is the onewhose hash forms the address.
- Minting a token: the script that is run is the one whose hash forms the policyID of the token being minted.
- Reward withdrawal: the script that is run is the one whose hash forms thestaking address.
- Applying a certificate: the script that is run is the one whose hash forms thecertificate author’s credential.
Besides letting the node know which script to run, all transaction actionsindicate how to assemble arguments passed to that script. Alonzo introduced anew approach to transaction validation on Cardano due to the implementation ofPlutus scripts.
Ledger features
The Alonzo upgrade changed the data on the ledger as follows:
- Plutus scripts can lock UTXOs.
- A component, added to the contents of the output parts of UTXOs, enablesscript state-like functionality. In addition to assets and an address, a UTXOlocked by Plutus scripts also contains a datum. A datum is a piece of datathat can be thought of as an interpretation of the script state.
- There are a number of protocol parameters used to impose additionalvalidation requirements on transactions. These include upper limits oncomputational resources that scripts can consume.
To support Plutus scripts, transactions have the following features:
- For each of its actions, the transaction carries a user-specified argument,called a redeemer. Depending on the script, a redeemer can serve a differentpurpose. For example, it can act as the bid the user places in an auction, orthe user’s guess in a guessing game, among many other functions.
- The transaction specifies computational execution budgets for each script.
- To ensure that a transaction can pay its execution fee, Alonzo introducedcollateral.
- Transactions contain an integrity hash, needed to ensure that it has not beencompromised, outdated, etc.
With the Vasil upgrade, Plutus scripts were upgraded to V2 functionality with animproved cost model and new built-ins. The use of reference inputs, inlinedatums, and reference scripts allowed for efficient throughput and significantlyincreased performance.See the complete Vasil feature overview here.
The node performs the checks that ensure the transaction is constructedcorrectly. For example, it must not exceed the maximum execution resourcebudget. It also invokes the Plutus script interpreter to run the scripts.
The non-deterministic gas model can charge users unpredictably large fees. InCardano scripts, this source of indeterminism is addressed by requiring that theresource budget itself, as well as the fee required to cover this budget, areincluded in the transaction. Script execution necessarily returns either Trueor False, and will not loop indefinitely. The reason for this is that everyoperation a script performs takes a non-zero amount of resources, which aretracked by the interpreter. If the budget specified by the transaction isexceeded, script execution terminates and returns False.
The following key points make the outcomes of script and transaction validationpredictable:
- the script interpreter will always terminate and return the same validationresult when applied to the same arguments
- a transaction necessarily fixes all arguments that will be passed to thescript interpreter during validation
- a transaction specifies all the actions it is taking that require scriptvalidation
- compulsory signatures on a transaction ensure that it cannot be altered by anadversary in a way that causes scripts to fail
- applying a transaction in the EUTXO ledger model is deterministic.
Script validation failure or success does affect how a transaction is processed.However, the True or False outcome, as well as ledger changes associatedwith either outcome, are predictable for a given transaction.