From d6149a790d108991df168891b545b0c85fca3a4a Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Thu, 9 Feb 2017 13:15:33 +0100 Subject: [PATCH] ethapi: bugfix for contract creation gas estimate --- internal/ethapi/api.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 4c8e784c5d..f7a4dd21e5 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -579,6 +579,11 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr r // EstimateGas returns an estimate of the amount of gas needed to execute the given transaction. func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*hexutil.Big, error) { + if args.To == nil { // contract creation, doCall returns immediately the used gas. + _, gas, err := s.doCall(ctx, args, rpc.PendingBlockNumber, vm.Config{}) + return (*hexutil.Big)(gas), err + } + // Binary search the gas requirement, as it may be higher than the amount used var lo, hi uint64 if (*big.Int)(&args.Gas).BitLen() > 0 {