-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Despite the documentation, method web3.eth.accounts.signTransaction does not allow passing chainId as String #3030
Comments
@3sGgpQ8H Which web3 version are you using? I am testing with web3 version 1.2.1. |
1.0.0-beta.55 |
It is working fine with the current version which is 1.2.1. Please check once. |
I looked through the code, and it seems that the actual problem was in So, 1.2.1 looks very different from both, 1.0.0-beta.55 and 2.x branch, and the fact that problem is not reproducible in 1.2.1 does not necessary mean, that it is not reproducible in 2.x. P.S. Yes, it seems that what is fixed in 1.2.1 is not fixed in 2.x: 1.2.1 implements transaction signing itself and properly converts 2.x delegates to ethereumjs-tx: https://github.com/ethereum/web3.js/blob/2.x/packages/web3-eth-accounts/src/Accounts.js#L162 https://github.com/ethereum/web3.js/blob/2.x/packages/web3-eth/src/signers/TransactionSigner.js#L63 So the problem is probably still reproducible on 2.x branch. |
Yes sure. I will try to reproduce it using 2.0 |
NB: Per comment above have re-labelled. In #3070 it's proposed to resolve some signing bugs by upgrading to ethereumjs-tx. Leaving a cross ref there so this problem isn't replicated in the new work. |
Just ran into this issue using Web3 + HDWalletProvider, both the most recent versions. I'm not sure what the solution is, but there should at least be an error thrown if the chainId is passed as a string. Returning a transaction signed by an incorrect key is really strange behavior, and took quite a while of debugging to figure out. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment, otherwise this issue will be closed in 7 days |
I believe this is still an issue and shouldn't be closed |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Bumping to keep this open |
@dmihal hm that's weird, it looks like the src uses numberToHex which should handle strings fine. could you share some code or a snippet to reproduce? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Description
Documentation for method
web3.eth.accounts.signTransaction
says that parameterchainId
is of typeString
, though example in the documentation setschainId
like this:i.e. as
number
not asstring
.Actually, when
chainId
is specified asstring
this method silently produces incorrect signature.Expected behavior
Method
web3.eth.accounts.signTransaction
allows specifyingchainId
and eitherstring
ornumber
and works properly in both cases.Actual behavior
Method
web3.eth.accounts.signTransaction
works correctly only whenchainId
is specified asnumber
, but whenchainId
is specified asstring
this method silently produces incorrect signature.Steps to reproduce the behavior
chainId
parameter to methodweb3.eth.accounts.signTransaction
asstring
.Versions
The text was updated successfully, but these errors were encountered: