Skip to content

Commit

Permalink
Replace max fee func and rename, add gasPrice to Mint
Browse files Browse the repository at this point in the history
  • Loading branch information
MitchTurner committed Feb 22, 2024
1 parent 3ba96bc commit b84d2ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/protocol/tx-validity.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ def max_gas(tx) -> int:
if tx.type == TransactionType.Script:
gas = gas + tx.gasLimit
return gas


def maxFee(tx, assetId, gasPrice) -> int:
"""
Computes the maximum potential amount of fees that may need to be charged to process a transaction.
"""
maxGas = max_gas(tx)
feeBalance = gas_to_fee(maxGas, gasPrice)
# Only base asset can be used to pay for gas
if assetId == 0:
return feeBalance
else:
return 0


def available_balance(tx, assetId) -> int:
Expand Down
15 changes: 8 additions & 7 deletions src/tx-format/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,14 @@ Creates a contract with contract ID as computed [here](../identifiers/contract-i
The transaction is created by the block producer and is not signed. Since it is not usable outside of block creation or execution, all fields must be fully set upon creation without any zeroing.
This means that the transaction ID must also include the correct `txPointer` value, not zeroed out.

| name | type | description |
|------------------|-------------------------------|------------------------------------------------------|
| `txPointer` | [`TXPointer`](./tx-pointer.md) | The location of the `Mint` transaction in the block. |
| `inputContract` | [`InputContract`](./input.md) | The contract UTXO that assets are minted to. |
| `outputContract` | [`OutputContract`](./output.md) | The contract UTXO that assets are being minted to. |
| `mintAmount` | `uint64` | The amount of funds minted. |
| `mintAssetId` | `byte[32]` | The asset IDs corresponding to the minted amount. |
| name | type | description |
|------------------|---------------------------------|----------------------------------------------------------------------------|
| `txPointer` | [`TXPointer`](./tx-pointer.md) | The location of the `Mint` transaction in the block. |
| `inputContract` | [`InputContract`](./input.md) | The contract UTXO that assets are minted to. |
| `outputContract` | [`OutputContract`](./output.md) | The contract UTXO that assets are being minted to. |
| `mintAmount` | `uint64` | The amount of funds minted. |
| `mintAssetId` | `byte[32]` | The asset IDs corresponding to the minted amount. |
| `gasPrice` | `uint64` | The gas price to be used in calculating all fees for transactions on block |

Transaction is invalid if:

Expand Down

0 comments on commit b84d2ec

Please sign in to comment.