From 7faaefc1526f66b34735c0f6bb49cddbabc28428 Mon Sep 17 00:00:00 2001 From: Valentin Matter Date: Wed, 15 Jun 2022 17:46:33 +0200 Subject: [PATCH] NonceManager: fix transaction count update when sending transaction This commit fixes an issue that leads to reused nonces in some cases. When passing a transaction with a defined nonce, the NonceManager uses that to set the transaction count, which leads to the same nonce being reused for the next transaction (if the nonce is `n`, there has been `n+1` transactions) --- packages/experimental/src.ts/nonce-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/experimental/src.ts/nonce-manager.ts b/packages/experimental/src.ts/nonce-manager.ts index 9cf16c5bf9..28588d7e29 100644 --- a/packages/experimental/src.ts/nonce-manager.ts +++ b/packages/experimental/src.ts/nonce-manager.ts @@ -63,7 +63,7 @@ export class NonceManager extends ethers.Signer { transaction.nonce = this.getTransactionCount("pending"); this.incrementTransactionCount(); } else { - this.setTransactionCount(transaction.nonce); + this.setTransactionCount(transaction.nonce + 1); } return this.signer.sendTransaction(transaction).then((tx) => {