Skip to content

Comments

Update guidance for calculateFee and scheduled transaction performance#1646

Open
joshuahannan wants to merge 2 commits intomainfrom
sch-tx-perf-tips
Open

Update guidance for calculateFee and scheduled transaction performance#1646
joshuahannan wants to merge 2 commits intomainfrom
sch-tx-perf-tips

Conversation

@joshuahannan
Copy link
Member

@joshuahannan joshuahannan commented Jan 27, 2026

Adds an article encouraging developers to use calculateFee() instead of estimate() for scheduled transactions and encourages them to calculate the size of their data ahead of time.

Also updates the existing scheduled transactions introduction to use this pattern too

Not planning on merging the second document because that is just a draft for a blog post

@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 17, 2026 4:31pm

Request Review

@joshuahannan
Copy link
Member Author

@Aliserag Any feedback on this or updates on the blog post?

priority: pr,
executionEffort: executionEffort
let est = FlowTransactionScheduler.calculateFee(
executionEffort: executionEffort, priority: pr, dataSizeMB: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to explain what is dataSizeMB, even if it's kind of straightforward and why here is 0. Just an explanation of the parameter like for executionEffort and priority.

Why this works: `manager.schedule()` does all the validation anyway, so you only need the fee upfront. Let `schedule()` handle the rest!

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add that the estimate function may still be useful to correctly manage the case in which you are scheduling with High priority and the selected slot is full so that you can reschedule because it returns null. what do you think?


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.

If your transaction data is always the same size, stop calculating it every time!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can have also the case in which you cannot use calculateSize, showing an example when the data change the size

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but in that case, they can still use getSizeOfData() and not estimate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants