diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index eaa743fe34..c7d1e0020f 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -963,6 +963,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash if err != nil { return 0, err } + if block == nil { + return 0, errors.New("block not found") + } hi = block.GasLimit() } // Recap the highest gas limit with account's available balance. diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 300c2b054f..e2b8ad1718 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -500,6 +500,13 @@ web3._extend({ params: 1, inputFormatter: [web3._extend.formatters.inputTransactionFormatter] }), + new web3._extend.Method({ + name: 'estimateGas', + call: 'eth_estimateGas', + params: 2, + inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter], + outputFormatter: web3._extend.utils.toDecimal + }), new web3._extend.Method({ name: 'submitTransaction', call: 'eth_submitTransaction',