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
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 }feeBufferparameter (default 1.2x) to the estimate to avoid under-budget failuresestimateSubmitFee(params),estimateFundFee(invoiceId)Suggested execution
sdk/src/utils/feeCalculator.tssdk/README.mdExample commit message
feat(sdk): add fee estimation utilities for pre-transaction cost preview