Skip to content

Commit 9d1f8e9

Browse files
committed
Correct fee history, script hash detail, and finality figures
1 parent e642b68 commit 9d1f8e9

9 files changed

Lines changed: 20 additions & 17 deletions

File tree

docs/developers/curriculum/dapps/listen-for-payments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function receivedLovelace(addr) {
109109
For a complete point-of-sale app with a React UI, QR codes, and live USD/ADA conversion, fork the [Cardano POS starter](https://github.com/fill-the-fill/cardano-pos-starting-point).
110110

111111
:::tip Wait for confirmations
112-
A transaction in a recent block can still be [rolled back](/docs/developers/curriculum/fundamentals/consensus-and-ouroboros#how-does-finality-work). Cardano produces a block roughly every 20 seconds, so for anything valuable wait 10-20 blocks (a few minutes) before treating a payment as final; the larger the amount, the deeper you should wait. Track deposits by transaction id and credit each one exactly once, only after your chosen depth, so a rollback that replays the same transaction cannot double-credit.
112+
A transaction in a recent block can still be [rolled back](/docs/developers/curriculum/fundamentals/consensus-and-ouroboros#how-does-finality-work). Cardano produces a block roughly every 20 seconds, so for anything valuable, wait 10-20 blocks (a few minutes) before treating a payment as final; the larger the amount, the deeper you should wait. Track deposits by transaction id and credit each one exactly once, only after your chosen depth, so a rollback that replays the same transaction cannot double-credit.
113113
:::
114114

115115
## Requesting a payment

docs/developers/curriculum/fundamentals/consensus-and-ouroboros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Short forks happen for two mundane reasons, and naming them removes the mystery.
9797

9898
When a leader produces a block it must reach other nodes fast (Cardano targets diffusion within ~5 seconds) or risk being orphaned. The parameter **k** (currently 2160) defines settlement: a block is considered settled once k blocks follow it, roughly 12 hours at ~20s/block. And k is not only a probability statement: nodes never adopt a chain that forks more than k blocks below their tip, so everything deeper than k is immutable by construction and only the last k blocks are ever up for revision.
9999

100-
In practice real forks are one or two blocks deep. Most applications treat 10-20 confirmations (a few minutes) as very safe for ordinary value; high-value receivers wait deeper, exchanges commonly 20-30 blocks or more; k is the absolute bound. The [Cardano Blueprint's chain selection page](https://cardano-scaling.github.io/cardano-blueprint/consensus/chainsel.html) covers the rule and its tie-breakers in detail.
100+
In practice forks are typically a block or two deep. Most applications treat 10-20 confirmations (a few minutes) as very safe for ordinary value; high-value receivers wait deeper, exchanges commonly 20-30 blocks or more; k is the absolute bound. The [Cardano Blueprint's chain selection page](https://cardano-scaling.github.io/cardano-blueprint/consensus/chainsel.html) covers the rule and its tie-breakers in detail.
101101

102102
### How do rewards and incentives drive decentralization?
103103

@@ -113,13 +113,13 @@ Decentralization is not enforced by a rule; it emerges from economic incentives
113113

114114
## How does finality work?
115115

116-
Cardano provides **probabilistic finality**: the chance of reversal decreases exponentially with each block added, and beyond k = 2160 blocks (~12 hours) reversal is impossible by construction, not merely unlikely. Practical finality is reached in 5-10 minutes.
116+
Cardano provides **probabilistic finality**: the chance of reversal decreases exponentially with each block added, and beyond k = 2160 blocks (~12 hours) chain selection refuses to roll back at all, making k a hard bound on rollback depth rather than a probability. Practical finality is 10-20 confirmations, a few minutes.
117117

118118
| Network | Typical finality | Mechanism |
119119
|---|---|---|
120120
| Bitcoin (PoW) | ~60 min (6 blocks) | Probabilistic |
121121
| Ethereum (PoS) | ~15 min | Deterministic after finalization |
122-
| Cardano (Praos) | ~5-10 min practical, ~12h bound | Probabilistic, stake-based |
122+
| Cardano (Praos) | ~3-7 min practical, ~12h bound | Probabilistic, stake-based |
123123

124124
## What happens during a complete epoch?
125125

docs/developers/curriculum/fundamentals/core-concepts/fees.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
id: fees
33
title: Transaction Fees
44
sidebar_label: Transaction fees
5-
description: Cardano's deterministic fee formula, script execution costs, and collateral.
5+
description: Cardano's deterministic fee formula, script execution and reference script costs, and collateral.
66
---
77

8-
Transaction fees on Cardano are deterministic and predictable. They are calculated from a simple linear formula based on transaction size (plus script execution cost), so you can compute the exact fee before submitting, with no auctions and no gas-price spikes.
8+
Transaction fees on Cardano are deterministic and predictable. They are calculated from a simple linear formula based on transaction size (plus script execution and reference script costs), so you can compute the exact fee before submitting, with no auctions and no gas-price spikes.
99

1010
If you have used a metered cloud API, fees will feel familiar: just as an API charges per request and throttles abuse, Cardano charges per transaction by size and complexity, pricing both bandwidth (size) and compute (ExUnits). Collateral works like a pre-authorized hold or security deposit: if your script crashes and consumes node resources, the deposit covers it; if everything succeeds, you keep it.
1111

@@ -49,17 +49,19 @@ When a transaction runs Plutus scripts (spending from a script address, minting
4949
flowchart TD
5050
A["Transaction size (bytes)"] --> B["Size fee: a * size + b"]
5151
C["Script execution (CPU + memory)"] --> D["Script fee: cpu*price_cpu + mem*price_mem"]
52+
F["Referenced script bytes"] --> G["Ref-script fee: tiered per byte"]
5253
B --> E["Total fee"]
5354
D --> E
55+
G --> E
5456
```
5557

5658
Script costs are measured in **execution units (ExUnits)**: memory units (peak memory) and CPU steps (CPU budget). The script fee is `mem_price * memory_units + step_price * cpu_steps`, added to the size fee. Transaction-building libraries simulate execution to compute ExUnits automatically before submission, see the Evolution SDK's [script evaluation](https://github.com/IntersectMBO/evolution-sdk) for how this works under the hood.
5759

5860
## Reference script fees
5961

60-
Transactions that use [reference scripts](/docs/developers/curriculum/fundamentals/core-concepts/transactions#reference-inputs-and-reference-scripts) pay a third component: every byte of every script the transaction references is charged, starting at 15 lovelace per byte (the `minFeeRefScriptCostPerByte` parameter, set through governance). The price is tiered: for each successive 25,600-byte increment of total referenced script size, the per-byte price multiplies by 1.2, so referencing a few kilobytes costs a fraction of an ADA while very large reference scripts get progressively expensive. Only the script's own serialized bytes count, not the CBOR wrapping around them.
62+
Transactions that use [reference scripts](/docs/developers/curriculum/fundamentals/core-concepts/transactions#reference-inputs-and-reference-scripts) pay a third component: every byte of every reference script carried by the transaction's inputs, spent or referenced, used or not, is charged, starting at 15 lovelace per byte (the `minFeeRefScriptCostPerByte` parameter, set through governance). The price is tiered: for each successive 25,600-byte increment of total referenced script size, the per-byte price multiplies by 1.2, so referencing a few kilobytes costs a fraction of an ADA while very large reference scripts get progressively expensive, up to a hard cap of 200 KiB of referenced script per transaction. Only the script bytes themselves count, not the CBOR tag and Plutus version number the ledger wraps around them.
6163

62-
The tiering exists because a referenced script is cheap for the transaction that names it but real work for every node, which must fetch and deserialize it. After that asymmetry was exploited on mainnet in 2024, the pricing moved from linear to escalating: ordinary scripts stay cheap, abuse prices itself out. For a fully worked mainnet example, from raw CBOR to the final lovelace, see the [Cardano Blueprint's transaction fee page](https://cardano-scaling.github.io/cardano-blueprint/ledger/transaction-fee.html).
64+
The fee exists because a referenced script is cheap for the transaction that names it but real work for every node, which must fetch and deserialize it. Reference scripts were free when Babbage introduced them, and that asymmetry was attacked on mainnet in June 2024; Conway priced them, with an escalating rather than flat rate, so ordinary scripts stay cheap while abuse prices itself out. For a fully worked mainnet example, from raw CBOR to the final lovelace, see the [Cardano Blueprint's transaction fee page](https://cardano-scaling.github.io/cardano-blueprint/ledger/transaction-fee.html).
6365

6466
## Collateral
6567

@@ -75,7 +77,7 @@ Rules:
7577
- **Consumed only** if phase-2 validation fails.
7678
- **Collateral return (CIP-40):** since Vasil, a transaction can specify a collateral return address so only the required amount is taken, not the entire UTXO.
7779

78-
Losing collateral is avoidable in practice. Phase-2 validation is deterministic: it depends only on the transaction and the outputs it spends or references, so a script that passed when you evaluated it locally cannot fail on-chain against those same inputs. If the chain changes underneath the transaction, say an input gets spent first, it fails phase 1 instead, which costs nothing. A submitter who validates before submitting should never actually forfeit collateral. The CIP-40 return address exists for the case where you cannot pre-validate because a third party evaluates scripts on your behalf; before it, whatever UTXO you put up as collateral was at risk in its entirety rather than just the required amount.
80+
Losing collateral is avoidable in practice. Phase-2 validation is deterministic: it depends only on the transaction and the outputs it spends or references, so a script that passed when you evaluated it locally cannot fail on-chain against those same inputs. If the chain changes underneath the transaction, say an input gets spent first, it fails phase 1 instead, which costs nothing. A submitter who validates before submitting should never forfeit collateral. The CIP-40 return address exists for the case where you cannot pre-validate because a third party evaluates scripts on your behalf.
7981

8082
This is the canonical reference for collateral; the [transaction lifecycle](/docs/developers/curriculum/fundamentals/core-concepts/transactions#deterministic-outcomes) and [Smart Contracts](/docs/developers/curriculum/smart-contracts/overview) link here.
8183

@@ -92,7 +94,8 @@ It's a real tuning axis, not just theory:
9294
## Key takeaways
9395

9496
- Fees are deterministic: `fee = a * size + b`, knowable exactly before submission.
95-
- Script transactions add an ExUnits-based execution fee on top of the size fee; builders compute it automatically. Reference scripts add a third, per-byte fee that escalates in tiers for very large scripts.
97+
- Script transactions add an ExUnits-based execution fee on top of the size fee; builders compute it automatically.
98+
- Reference scripts add a third, per-byte fee that escalates in tiers for very large scripts.
9699
- Collateral (ADA-only) is forfeited only on phase-2 script failure; CIP-40 returns the excess.
97100
- Fees are pooled and distributed across block-producing stake pools each epoch.
98101

docs/developers/curriculum/fundamentals/core-concepts/transactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Once a transaction passes submission validation and enters the mempool, it is gu
146146
### Latency vs finality
147147

148148
- **Latency**: time to appear in a block (~20s average block time).
149-
- **Finality**: time to become practically irreversible. Depends on your risk tolerance; most applications treat [10-20 confirmations, a few minutes,](/docs/developers/curriculum/fundamentals/consensus-and-ouroboros#how-does-finality-work) as strong finality, high-value transfers wait longer.
149+
- **Finality**: time to become practically irreversible. Depends on your risk tolerance; most applications treat [10-20 confirmations](/docs/developers/curriculum/fundamentals/consensus-and-ouroboros#how-does-finality-work) (a few minutes) as strong finality, high-value transfers wait longer.
150150

151151
## Serialization (CBOR)
152152

docs/developers/curriculum/production/transaction-chaining.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ graph LR
3636
style B fill:#FFFFFF,stroke:#0033AD,stroke-width:2px,color:#000000
3737
```
3838

39-
Under the hood the mempool is an ordered sequence. The node validates each arriving transaction against a recent chain tip (the mempool's *anchor*) plus everything already in the sequence, and order is preserved, so a producing transaction always sits ahead of its spender. When the tip changes, the node revalidates the sequence in order, and a transaction that drops out forces everything after it to be rechecked, because later transactions may have been building on it. That is the mechanical reason a chain lives or dies with its first link: lose it, and every dependent transaction is invalidated in the same sweep. The [Cardano Blueprint's mempool page](https://cardano-scaling.github.io/cardano-blueprint/mempool/index.html) documents this sequence machinery in full.
39+
Under the hood the mempool is an ordered sequence, validated against a recent ledger state (its *anchor*). In the reference node, a change of tip revalidates the sequence in order, and a transaction that drops out forces everything after it to be rechecked, because later transactions may have been building on it. The ledger only requires that a producing transaction come before its spender; a dependency-aware mempool could recheck less. The [Cardano Blueprint's mempool page](https://cardano-scaling.github.io/cardano-blueprint/mempool/index.html) documents this machinery in full.
4040

4141
Once a transaction is accepted into the mempool it keeps its place [toward inclusion](/docs/developers/curriculum/fundamentals/core-concepts/transactions#the-transaction-lifecycle) for as long as it stays valid against the node's evolving view of the chain. The chain as a whole, though, is only as durable as its first link.
4242

docs/developers/curriculum/smart-contracts/advanced/design-patterns/merkelized-validator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ script size.
1717

1818
We can take advantage of reference scripts and the withdraw-zero trick to separate the logic (and code) of our validator across a number of stake scripts (which we provide as reference inputs). Then our main validator simply checks for the presence of the associated staking script in the redeemers (and verifies that the redeemer to the scripts are as expected) where necessary to execute the branch of logic.
1919

20-
This is useful because with reference scripts this essentially gives us the ability to create scripts with near infinite size which means optimization strategies that involve increasing script size to reduce mem / CPU (ie loop unrolling) now are available to us at nearly zero cost.
20+
This is useful because with reference scripts this essentially gives us the ability to create scripts with near infinite size which means optimization strategies that involve increasing script size to reduce mem / CPU (ie loop unrolling) now are available to us. The referenced bytes still pay the [tiered reference script fee](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees), but that is far below carrying the script inline.
2121

2222
Consider a batching architecture, with a very large `processOrders` function. Normally it would not be feasible to perform recursion unrolling / inlining optimizations with such a function since it would quickly exceed the max script size limit; however, with this design pattern we simply move `processOrders` into its own validator script which we can fill with 16kb of loop unrolling and other powerful optimizations which increase script size in order to reduce ExUnits. We provide this new script as a reference script when executing our main validator. Then in our main validator we verify that the `processOrders` validator was executed with the expected redeemer (`input_arg` must match the arguments we want to pass to `processOrders`) after which we have access to the result of the optimized `processOrders` function applied to our inputs.
2323

@@ -28,7 +28,7 @@ Since transaction size is limited in Cardano, some scripts benefit from a soluti
2828
This design pattern offers an interface for off-loading such validations into an external observer/withdrawal script, so that the sizes of the scripts themselves can stay within the limits of Cardano.
2929

3030
:::note
31-
Be aware that total size of reference scripts is currently limited to 200KiB (204800 bytes), and they also impose additional fees in an exponential manner. See [here](https://github.com/IntersectMBO/cardano-ledger/issues/3952) and [here](https://github.com/CardanoSolutions/ogmios/releases/tag/v6.5.0) for more info.
31+
Be aware that total size of reference scripts is currently limited to 200KiB (204800 bytes), and they impose [per-byte fees that escalate in tiers](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees).
3232
:::
3333

3434
### Key Types

docs/developers/curriculum/smart-contracts/advanced/uplc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ This type system allows high-level languages to serialize complex data structure
8888

8989
### Binary Encoding and Execution
9090

91-
On-chain, UPLC programs are stored as compact binary data using the "flat" encoding format. This binary representation is what validators actually receive and execute. The flat blob is then wrapped in a CBOR byte string, and the script hash that addresses the script on-chain is computed over that wrapper, which is why script bytes sometimes appear double-CBOR-encoded in tooling. The [reference script fee](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees) is metered on the script's own serialized bytes.
91+
On-chain, UPLC programs are stored as compact binary data using the "flat" encoding format. This binary representation is what validators actually receive and execute. The flat blob is then wrapped in a CBOR byte string, and the script hash that addresses the script on-chain is computed over a one-byte language tag (PlutusV1, V2, or V3) followed by that wrapper. That is why identical bytes hash differently under different Plutus versions, and why script bytes sometimes appear double-CBOR-encoded in tooling. The [reference script fee](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees) is metered on those same wrapped bytes, the language tag aside.
9292

9393
**Size Implications**: UPLC programs can be large, which is why transaction size limits (16KB) become important for complex smart contracts. Recent improvements like reference scripts help mitigate this.
9494

docs/developers/curriculum/smart-contracts/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ A few ledger features shape how you design contracts:
146146

147147
- **Reference inputs ([CIP-31](https://cips.cardano.org/cip/CIP-31))**: read a UTXO's data without spending it, so many contracts can read one oracle feed at once.
148148
- **Inline datums ([CIP-32](https://cips.cardano.org/cip/CIP-32))**: store the datum in the output itself instead of a hash. See [Datum, redeemer & context](/docs/developers/curriculum/smart-contracts/datum-redeemer-context#datum-hash-vs-inline-datum).
149-
- **Reference scripts ([CIP-33](https://cips.cardano.org/cip/CIP-33))**: deploy a script once and reference it from later transactions. The transactions shrink; the referenced script pays a smaller [per-byte fee](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees) of its own. See [Lock and spend](/docs/developers/curriculum/smart-contracts/lock-and-spend#reference-scripts).
149+
- **Reference scripts ([CIP-33](https://cips.cardano.org/cip/CIP-33))**: deploy a script once and reference it from later transactions. The transaction shrinks, and the referenced bytes carry a [per-byte fee](/docs/developers/curriculum/fundamentals/core-concepts/fees#reference-script-fees) well below the cost of inlining. See [Lock and spend](/docs/developers/curriculum/smart-contracts/lock-and-spend#reference-scripts).
150150
- **Collateral output ([CIP-40](https://cips.cardano.org/cip/CIP-40))**: return excess collateral to an address you choose.
151151

152152
A validator's rules cannot be changed after deployment, and the compiled code cannot be turned back into source.

0 commit comments

Comments
 (0)