Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion docs/learn/fundamentals/fees-resource-limits-metering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ description: "Learn how fees, resource limits, and metering work on the Stellar
sidebar_position: 70
---

todo mermaid !

# Fees, Resource Limits, and Metering

## Fees overview
Expand All @@ -29,7 +31,32 @@ All smart contract transactions require a resource fee in addition to an inclusi

Transactions that do not execute a smart contract can be thought of as having a resource fee of zero (`resourceFee == 0`). Conversely, for smart contract transactions, you can subtract the resource fee from the total transaction fee to derive the equivalent classic transaction fee component, which is the inclusion fee.

![Soroban Fees](/assets/diagrams/soroban_fees.png) _\* Diagram: Solid line boxes are what is actually present in the transaction, while dotted lines are derivable._
```mermaid

block-beta
columns 4

txFee["tx.fee"]:4

resourceFee["tx.v1.sorobanData.resourceFee"]:3
inclusionFeeTop["inclusion<br/>fee"]:1

fixed["fixed resource fee<br/>calculated based on<br/>tx.v1.sorobanData.resources.*<br/><br/>instructions<br/>read<br/>write<br/>bandwidth<br/>(size of tx)"]:2
refundable["refundable<br/>resource fee<br/><br/>rent<br/>events<br/>return value"]:1
inclusionFeeBottom["inclusion<br/>fee"]:1

style inclusionFeeTop stroke-dasharray: 8 6
style fixed stroke-dasharray: 8 6
style refundable stroke-dasharray: 8 6
style inclusionFeeBottom stroke-dasharray: 8 6

```

:::note

Solid line boxes are what is actually present in the transaction, while dotted lines are derivable.

:::

Smart contracts on Stellar use a multidimensional resource fee model that charges fees for several resource types using [network-defined rates](https://lab.stellar.org/network-limits) on the Stellar Lab. The resource fee is calculated based on the resource consumption declared in the transaction and can fluctuate based on a mutable storage write fee (more on that in the [Storage Dynamic Pricing section](#dynamic-pricing-for-storage) below). If the transaction attempts to exceed the declared resource limits, it will fail. If the transaction uses fewer resources than declared, there will be no refunds [(with a couple of exceptions)](#refundable-and-non-refundable-resource-fees).

Expand Down
Binary file removed static/assets/diagrams/soroban_fees.png
Binary file not shown.
Loading