Skip to content

feat: fees and tip helpers #1434

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

Merged
merged 7 commits into from
Jul 28, 2025
Merged

Conversation

PhilippeR26
Copy link
Collaborator

@PhilippeR26 PhilippeR26 commented Jul 4, 2025

Motivation and Resolution

  1. Tip is now operational in Rpc 0.9. Nothing is helping the user to choose a value.
  2. ResourceBounds customization. It's complicated to customize the margins.
  3. It's not easy to get the 3 gas prices.

Usage related changes

Based on what is available in Ethereum SDKs (viem, ethers, web3), some new helpers are added:
These functions are available only for Rpc 0.8 onwards.

1. To get blockchain statistics of the use of Tip:

const tipStats0: TipStats | undefined = await myProvider.getTipStatsFromBlocks();

Note

default values are highly negociable.

2. To customize easily the margins of a ressourceBounds:

const estimate: EstimateFee = await account0.estimateInvokeFee(myCall);
const resourceBounds = stark.setResourceBounds(estimate, 100, 10);
const res = await account0.execute(myCall, {
    resourceBounds,
    tip: 1n * 10n ** 9n
});

3. To get the gas prices:

const gasPrices0: GasPrices = await myProvider.getGasPrices();

Development related changes

  • getGasPrices() and getTipStatsFromBlocks() are located in RPC08.RpcChannel.
  • setResourceBounds() is located in stark/rpc08.
  • new types are in a new tip.type.ts file, in provider/types.

Important

PR to merge in the RPC 0.9 branch.

Note

  • in this draft PR, the new features are implemented in RPC 0.8. To see where will be the right final location.
  • tests & guides are not yet implemented.

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

@tabaktoni tabaktoni changed the base branch from develop to beta July 17, 2025 07:29
@@ -229,6 +235,18 @@ export function estimateFeeToBounds(
return estimateFeeToBoundsRPC07(estimate, overhead as ResourceBoundsOverheadRPC07); // TODO: remove as
}

export function setResourceBounds(
Copy link
Member

Choose a reason for hiding this comment

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

Now can use toOverheadResourceBounds

@PhilippeR26
Copy link
Collaborator Author

As discussed, only item 3 has been kept.

@PhilippeR26 PhilippeR26 requested a review from tabaktoni July 25, 2025 09:16
@PhilippeR26 PhilippeR26 marked this pull request as ready for review July 25, 2025 09:18
public async getGasPrices(
blockIdentifier: BlockIdentifier = this.channel.blockIdentifier
): Promise<GasPrices> {
if (this.channel instanceof RPC09.RpcChannel) return this.channel.getGasPrices(blockIdentifier);
Copy link
Member

Choose a reason for hiding this comment

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

Why dont add implementation also to RPC 0.8 and include it into Provider ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Modified.

@PhilippeR26 PhilippeR26 changed the base branch from beta to develop July 28, 2025 14:54
Copy link
Member

@tabaktoni tabaktoni left a comment

Choose a reason for hiding this comment

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

LGTM

@tabaktoni tabaktoni merged commit fd07294 into starknet-io:develop Jul 28, 2025
3 checks passed
Copy link
Contributor

🎉 This PR is included in version 8.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants