You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// get current nonce for faucet account
const startNonce = await ethers.provider.getTransactionCount(faucet.address);
// transfer 1 ether gas tokens to all accounts concurrently with explicit nonces
const transferPromises = initialAccounts.map((account, index) =>
faucet.sendTransaction({
to: account.address,
value: ethers.parseEther("1"),
nonce: startNonce + index // increment nonce for each transaction
})
);
// wait for all transactions to be mined
const txs = await Promise.all(transferPromises);
await Promise.all(txs.map(tx =>tx.wait()));
// verify balances
await Promise.all(
initialAccounts.map(async account => {
expect(await ethers.provider.getBalance(account.address))
.to.be.greaterThanOrEqual(ethers.parseEther("1"));
})
);
with this test code, concurrently sending txs from the same account would result in nonce-mismatch error: ProviderError: invalid nonce; got 12, expected 13: invalid sequence: invalid sequence, even if you assign the correct nonce for each tx, because the tx with higher nonce may reach the mempool earlier and it would be rejected instead of staying in mempool and wait for txs with lower nonces to be processed. This behavior may need to be optimized to improve user experience and to align with other EVM-comaptible chains
The text was updated successfully, but these errors were encountered:
Description
with this test code, concurrently sending txs from the same account would result in nonce-mismatch error:
ProviderError: invalid nonce; got 12, expected 13: invalid sequence: invalid sequence
, even if you assign the correct nonce for each tx, because the tx with higher nonce may reach the mempool earlier and it would be rejected instead of staying in mempool and wait for txs with lower nonces to be processed. This behavior may need to be optimized to improve user experience and to align with other EVM-comaptible chainsThe text was updated successfully, but these errors were encountered: