-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nonce value is same when using two instance for two chains #4500
Comments
have created a reproducible repo - https://github.com/ujjwalguptaofficial/web3-nonce-issue |
@ujjwalguptaofficial Just wanted to let you know that I'm starting work on this now, apologies that it's been pending for so long Thank you for bringing this to our attention, and thank you especially for taking the time to make a reproducible repo! |
In my testing, this bug only seems to appear when both requests are sent with web3.eth.getTransactionCount(from, 'pending');
web3.eth.getTransactionCount(from2, 'pending'); Yields duplicate count from first request web3.eth.getTransactionCount(from, 'pending');
web3.eth.getTransactionCount(from2, 'latest'); // This could be anything besides 'pending', also order of calls doesn't matter Yields correct respective counts |
This seems to be an issue with Instantiating two instance like so: const web3Parent = new Web3(rpc.parent)
const web3Child = new Web3(rpc.child) Yields the correct result |
@ujjwalguptaofficial I can't provide you more information on this (can't seem to find an issue in Truffle repo for it, even though there's a comment about it), but it seems setting the option const web3Parent = new Web3(new HDWalletProvider(
privateKey,
rpc.parent,
0, // addressIndex
1, // numberOfAddresses
false //shareNonce
))
const web3Child = new Web3(new HDWalletProvider(privateKey, rpc.child)) For readability sake, this can be written as: const web3Parent = new Web3(new HDWalletProvider({
privateKeys: [privateKey],
providerOrUrl: rpc.parent,
shareNonce: false
}))
const web3Child = new Web3(new HDWalletProvider(privateKey, rpc.child)) Both of the above will result in the correct nonces being returned I'm going to close this issue as it's not related to Web3.js |
thanks @spacesailor24 :) |
Is there an existing issue for this?
Current Behavior
If i have two web3js instance with two different chains and i call
getTransactionCount
then value is being copied from first call.If i call
getTransactionCount
on parent first then value from parent will be returned in child.Expected Behavior
value should be different on each chain.
Steps to Reproduce
Here is reproducible repo - https://github.com/ujjwalguptaofficial/web3-nonce-issue
Web3.js Version
1.6.0
Environment
Anything Else?
No response
The text was updated successfully, but these errors were encountered: