Skip to content

Implement sdk/src/utils/feeCalculator.ts for pre-transaction fee estimation #373

Description

@Levi-Ojukwu

Description
Integrators need to estimate Soroban transaction fees before signing to give users accurate cost previews. The SDK should provide a fee estimation utility that simulates transactions and returns the fee in XLM.

Requirements and context

  • estimateFee(operation: SorobanOperation): Promise<{ feeXLM: string, feeStroops: bigint }
  • Internally uses Soroban's simulation endpoint to get the resource footprint
  • Add a feeBuffer parameter (default 1.2x) to the estimate to avoid under-budget failures
  • Expose per-method convenience functions: estimateSubmitFee(params), estimateFundFee(invoiceId)
  • Write tests with mocked simulation responses

Suggested execution

git checkout -b feat/sdk-fee-estimator
  • Create sdk/src/utils/feeCalculator.ts
  • Write unit tests for each convenience function
  • Document in sdk/README.md

Example commit message
feat(sdk): add fee estimation utilities for pre-transaction cost preview


Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions