From e06eaafd7b5e3beae74b15e0c37b489a746d01b0 Mon Sep 17 00:00:00 2001 From: abrahamcruise321 <100140860+abrahamcruise321@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:48:04 +0800 Subject: [PATCH] ethpoint GasPrice() return default 50 Gwei. (#23) --- jsonrpc/eth_endpoint.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jsonrpc/eth_endpoint.go b/jsonrpc/eth_endpoint.go index 0601464e23..713a8d7f01 100644 --- a/jsonrpc/eth_endpoint.go +++ b/jsonrpc/eth_endpoint.go @@ -425,8 +425,18 @@ func (e *Eth) GetStorageAt( // GasPrice returns the average gas price based on the last x blocks func (e *Eth) GasPrice() (interface{}, error) { + var avgGasPrice string + // Grab the average gas price and convert it to a hex value - avgGasPrice := hex.EncodeBig(e.store.GetAvgGasPrice()) + minGasPrice := new(big.Int).Mul( + big.NewInt(50), + new(big.Int).Exp(big.NewInt(10), big.NewInt(9), nil)) + + if e.store.GetAvgGasPrice().Cmp(minGasPrice) == -1 { + avgGasPrice = hex.EncodeBig(minGasPrice) + } else { + avgGasPrice = hex.EncodeBig(e.store.GetAvgGasPrice()) + } return avgGasPrice, nil }