Skip to content

Commit 0ad4077

Browse files
committed
respond to PR comments
1 parent 61d4917 commit 0ad4077

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/blockchain-development-tutorials/forte/scheduled-transactions/scheduled-transactions-introduction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ The `executionEffort` is also supplied as an argument in the transaction. This r
290290
To create the vault, the `calculateFee()` function calculates the amount needed:
291291

292292
```cadence
293+
// Calculates the estimated fee for the provided execution effort, priority, and transaction data size (in megabytes)
294+
// If the scheduled transaction has no data for its `data` argument, then the data size can be zero
293295
let est = FlowTransactionScheduler.calculateFee(
294296
executionEffort: executionEffort, priority: pr, dataSizeMB: 0
295297
)
@@ -465,7 +467,7 @@ let priority = FlowTransactionScheduler.Priority.Medium
465467
let executionEffort: UInt64 = 1000
466468
```
467469

468-
Next, add the `calculateFee()` call to calculate the fee for the scheduled transaction and ensure that a handler for the scheduled transaction exists.
470+
Next, add the `calculateFee()` call to calculate the fee for the scheduled transaction and ensure that a handler for the scheduled transaction exists. Your transaction does not provide and accompanying data, so your `dataSizeMB` argument can be zero.
469471

470472
```cadence
471473
let estimate = FlowTransactionScheduler.calculateFee(

docs/blockchain-development-tutorials/forte/scheduled-transactions/scheduled-tx-performance.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Why this works: `manager.schedule()` does all the validation anyway, so you only
6363

6464
In the long run, this will save a TON on transaction fees, especially if your app is scheduling a lot of recurring transactions!
6565

66+
One case where the `estimate()` function still may be useful is if you are scheduling a high priority transaction. These fail if there is no space in the requested timestamp, so it could be useful to see if that still fits with `estimate()`. Otherwise, you should always use `calculateFee()` instead!
67+
6668
## Bonus Optimization: Store Known Sizes
6769

6870
Scheduled Transactions can provide an optional piece of data when scheduling to be included with the transaction. The user must pay a fee for the storage of this data, so the contract needs to know its size.
@@ -87,6 +89,8 @@ let fee = FlowTransactionScheduler.calculateFee(executionEffort, priority, dataS
8789

8890
Pro tip: If your scheduled transaction payload is standardized with same fields and similar values, calculate the size once and store it in a configurable field in your contract or resource.
8991

92+
Remember, even if your data size changes each time, you still don't need `estimate()` every time. You can use `FlowTransactionScheduler.getSizeOfData()` to get the size for `calculateFee()`.
93+
9094
## Real World Examples
9195

9296
### Before: Inefficient Code

0 commit comments

Comments
 (0)