Skip to content

Commit

Permalink
Update txn-fees.mdx
Browse files Browse the repository at this point in the history
Signed-off-by: Meaghan FitzGerald <[email protected]>
  • Loading branch information
meaghanfitzgerald authored Dec 13, 2024
1 parent c54fdec commit b3b4918
Showing 1 changed file with 36 additions and 40 deletions.
76 changes: 36 additions & 40 deletions content/docs/api-reference/standards/guides/txn-fees.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,19 @@ title: Transaction Fees

In order to prevent spam, transactions on Avalanche require the payment of a transaction fee. The fee is paid in AVAX. **The transaction fee is burned (destroyed forever).**

When you issue a transaction through Avalanche's API, the transaction fee is automatically deducted from one of the addresses you control.
When you issue a transaction through Avalanche's API, the transaction fee is automatically deducted from one of the addresses you control.

Fee Schedule[](#fee-schedule "Direct link to heading")
The [avalanchego wallet](https://github.com/ava-labs/avalanchego/blob/master/wallet/chain) contains example code written in golang for building and signing transactions on all three mainnet chains.

X-Chain Fees[](#fee-schedule)
-------------------------------------------------------

Different types of transactions require payment of a different transaction fee. This table shows the transaction fee schedule:
The X-Chain currently operates under a fixed fee mechanism. This table shows the X-Chain transaction fee schedule:

```
+----------+---------------------------+--------------------------------+
| Chain | Transaction Type | Mainnet Transaction Fee (AVAX) |
+----------+---------------------------+--------------------------------+
| P | Create Layer 1 | 1 |
+----------+---------------------------+--------------------------------+
| P | Create Blockchain | 1 |
+----------+---------------------------+--------------------------------+
| P | Add Validator | 0 |
+----------+---------------------------+--------------------------------+
| P | Add Avalanche L1 Validator | 0.001 |
+----------+---------------------------+--------------------------------+
| P | Add Permissionless | Primary Network: 0 |
| | Validator | Avalanche L1: 0.001 |
+----------+---------------------------+--------------------------------+
| P | Add Delegator | 0 |
+----------+---------------------------+--------------------------------+
| P | Add Avalanche L1 Delegator | 0.001 |
+----------+---------------------------+--------------------------------+
| P | Add Permissionless | Primary Network: 0 |
| | Delegator | Avalanche L1: 0.001 |
+----------+---------------------------+--------------------------------+
| P | Import AVAX | 0.001 |
+----------+---------------------------+--------------------------------+
| P | Export AVAX | 0.001 |
+----------+---------------------------+--------------------------------+
| X | Send | 0.001 |
+----------+---------------------------+--------------------------------+
| X | Create Asset | 0.01 |
Expand All @@ -47,24 +27,14 @@ Different types of transactions require payment of a different transaction fee.
+----------+---------------------------+--------------------------------+
| X | Export AVAX | 0.001 |
+----------+---------------------------+--------------------------------+
| C | Simple send | >= 0.001575* |
+----------+---------------------------+--------------------------------+
(*) C-Chain gas price varies. See below.
```

On Fuji Testnet, all fees are the same as those on Mainnet, except the following ones:

- Create Avalanche L1: 0.1 AVAX
- Create Blockchain: 0.1 AVAX

C-Chain Fees[](#c-chain-fees "Direct link to heading")
C-Chain Fees[](#c-chain-fees)
-------------------------------------------------------

The Avalanche C-Chain uses an algorithm to determine the "base fee" for a transaction. The base fee increases when network utilization is above the target utilization and decreases when network utilization is below the target.

### Dynamic Fee Transactions[](#dynamic-fee-transactions "Direct link to heading")
### Dynamic Fee Transactions[](#dynamic-fee-transactions )

Transaction fees for non-atomic transactions are based on Ethereum's EIP-1559 style Dynamic Fee Transactions, which consists of a gas fee cap and a gas tip cap.

Expand All @@ -78,16 +48,16 @@ Transactions are ordered by the priority fee, then the timestamp (oldest first).

Based off of this information, you can specify the `gasFeeCap` and `gasTipCap` to your liking based on how you prioritize getting your transaction included as quickly as possible vs. minimizing the price paid per unit of gas.

#### Base Fee[](#base-fee "Direct link to heading")
#### Base Fee[](#base-fee)

The base fee can go as low as 25 nAVAX (Gwei) and has no upper bound. You can use the [`eth_baseFee`](/api-reference/c-chain/api#eth_basefee) and [eth\_maxPriorityFeePerGas](/api-reference/c-chain/api#eth_maxpriorityfeepergas) API methods, or [Snowtrace's C-Chain Gas Tracker](https://snowtrace.io/gastracker), to estimate the gas price to use in your transactions.

#### Further Readings[](#further-readings "Direct link to heading")
#### Further Readings[](#further-readings)

- [Adjusting Gas Price During High Network Activity](/dapps/advanced-tutorials/manually-adjust-gas-price)
- [Sending Transactions with Dynamic Fees using JavaScript](/dapps/advanced-tutorials/dynamic-gas-fees)

### Atomic Transaction Fees[](#atomic-transaction-fees "Direct link to heading")
### Atomic Transaction Fees[](#atomic-transaction-fees)

C-Chain atomic transactions (that is imports and exports from/to other chains) charge dynamic fees based on the amount of gas used by the transaction and the base fee of the block that includes the atomic transaction.

Expand All @@ -108,3 +78,29 @@ Gas Used:
Therefore, the gas used by an atomic transaction is `1 * len(unsignedTxBytes) + 1,000 * numSignatures + 10,000`

The TX fee additionally takes the base fee into account. Due to the fact that atomic transactions use units denominated in 9 decimal places, the base fee must be converted to 9 decimal places before calculating the actual fee paid by the transaction. Therefore, the actual fee is: `gasUsed * baseFee (converted to 9 decimals)`.


P-Chain Fees[](#p-chain-fees)
-------------------------------------------------------

The Avalanche P-Chain utilizes a dynamic fee mechanism to optimize transaction costs and network utilization. This system adapts fees based on gas consumption to maintain a target utilization rate.

### Dimensions of Gas Consumption
Gas consumption is measured across four dimensions:

1. **Bandwidth** The transaction size in bytes.
2. **Reads** The number of state/database reads.
3. **Writes** The number of state/database writes.
4. **Compute** The compute time in microseconds.

The total gas consumed ($G$) by a transaction is:

```math
G = B + 1000R + 1000W + 4C
```

The current fee dimension weight configurations as well as the parameter configurations of the P-Chain can be read at any time with the [`platform.getFeeConfig`](https://docs.avax.network/api-reference/p-chain/api#platformgetfeeconfig) API endpoint.

### Fee Adjustment Mechanism
Fees adjust dynamically based on excess gas consumption, the difference between current gas usage and the target gas rate. The exponential adjustment ensures consistent reactivity regardless of the current gas price. Fee changes scale proportionally with excess gas consumption, maintaining fairness and network stability. The technical specification of this mechanism is documented in [ACP-103](https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/103-dynamic-fees/README.md#mechanism).

0 comments on commit b3b4918

Please sign in to comment.