Skip to content

Commit 780c79f

Browse files
authored
chore: use the gas price estimation endpoint in txclient (#191)
## Overview WHen the chain is full, I noticed sometimes fibre transactions taking a bit of time to be included. This PR helps with that by using the gas estimation endpoint instead of the hardcoded min value
1 parent 406da48 commit 780c79f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/user/tx_client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,11 @@ func (client *TxClient) BroadcastTx(ctx context.Context, msgs []sdktypes.Msg, op
483483
}
484484

485485
if !hasUserSetFee {
486-
fee := int64(math.Ceil(appconsts.DefaultMinGasPrice * float64(gasLimit)))
486+
gasPriceResp, err := client.gasEstimationClient.EstimateGasPrice(ctx, &gasestimation.EstimateGasPriceRequest{})
487+
if err != nil {
488+
return nil, err
489+
}
490+
fee := int64(math.Ceil(gasPriceResp.EstimatedGasPrice * float64(gasLimit)))
487491
txBuilder.SetFeeAmount(sdktypes.NewCoins(sdktypes.NewCoin(appconsts.BondDenom, sdkmath.NewInt(fee))))
488492
}
489493

0 commit comments

Comments
 (0)