From 8f286f9d13e710231359e31ad5527b9939ea40d2 Mon Sep 17 00:00:00 2001 From: imterryyy Date: Wed, 27 Nov 2024 13:24:21 +0700 Subject: [PATCH] feat(internal/ethapi/api): Ask transaction pool for the nonce which includes pending transactions --- internal/ethapi/api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index eb69b8d1a..0d05884ca 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1617,6 +1617,15 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx cont // GetTransactionCount returns the number of transactions the given address has sent for the given block number func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error) { + // Ask transaction pool for the nonce which includes pending transactions + if blockNr == rpc.PendingBlockNumber { + nonce, err := s.b.GetPoolNonce(ctx, address) + if err != nil { + return nil, err + } + return (*hexutil.Uint64)(&nonce), nil + } + state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr) if state == nil || err != nil { return nil, err