Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support estimating contract calls fees #361

Merged
merged 6 commits into from
Jul 30, 2024

Conversation

djordon
Copy link
Contributor

@djordon djordon commented Jul 29, 2024

Description

Closes #233.

We need the current priority mempool fees for stacks transactions. This PR adds a function that uses the POST /v2/fees/transaction endpoint on stacks-core for this.

All fees returned are the high-priority fee amount (not the fee rate). And the implementation for estimating fees in the trait falls back on the high-priority STX transfer fee in the event that the node cannot estimate fees for the transaction.

Changes

  • Add a function that estimates transaction fees (for contract calls or otherwise).
  • Add a function to the StacksInterface trait for estimating fees, along with a "robust" implementation that falls back to the STX transfer fee estimate if the node does not know how much the particular transaction will cost.

Testing

This PR adds an integration test that should work with both a pre- and -post-nakamoto stacks-node. It's not set up to run in CI.

@djordon djordon added the sbtc bootstrap signer The sBTC Bootstrap Signer. label Jul 29, 2024
Copy link
Collaborator

@AshtonStephens AshtonStephens left a comment

Choose a reason for hiding this comment

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

Looks good, but I'd like a response to the "max" question I put even if we choose not to do it. Then I'll approve.

@AshtonStephens
Copy link
Collaborator

To move us along I'm happy to approve this ticket, but we should make a TODO note above the max part and then add a ticket. The one you just made could encompass the configuration feature as well.

@djordon
Copy link
Contributor Author

djordon commented Jul 30, 2024

To move us along I'm happy to approve this ticket, but we should make a TODO note above the max part and then add a ticket. The one you just made could encompass the configuration feature as well.

Done in 0092844

@djordon
Copy link
Contributor Author

djordon commented Jul 30, 2024

Okay, I made this more robust in #368.

Copy link
Contributor

@xoloki xoloki left a comment

Choose a reason for hiding this comment

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

Lgtm. I agree that using the max fee is suboptimal, but not worth holding up this PR

Copy link
Collaborator

@AshtonStephens AshtonStephens left a comment

Choose a reason for hiding this comment

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

LGTM.

@djordon djordon merged commit 66d5a56 into main Jul 30, 2024
4 checks passed
@djordon djordon deleted the 233-support-estimating-contract-calls-fees branch July 30, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sbtc bootstrap signer The sBTC Bootstrap Signer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Add support for estimating fees for sBTC contract calls
3 participants