From 97e7e2c59d6a4a6d9de3a0214fe592a2e0ac1945 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi <1591639+s1na@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:45:11 +0100 Subject: [PATCH] graphql: fix nonce for pending accounts (#24443) --- graphql/graphql.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index 16e0eb654d97f..44cee273a5f22 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -100,6 +100,14 @@ func (a *Account) Balance(ctx context.Context) (hexutil.Big, error) { } func (a *Account) TransactionCount(ctx context.Context) (hexutil.Uint64, error) { + // Ask transaction pool for the nonce which includes pending transactions + if blockNr, ok := a.blockNrOrHash.Number(); ok && blockNr == rpc.PendingBlockNumber { + nonce, err := a.backend.GetPoolNonce(ctx, a.address) + if err != nil { + return 0, err + } + return hexutil.Uint64(nonce), nil + } state, err := a.getState(ctx) if err != nil { return 0, err