Skip to content
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

Incorrect behavior for signTransaction function #2733

Closed
Senshii opened this issue Apr 25, 2019 · 0 comments · Fixed by #2735
Closed

Incorrect behavior for signTransaction function #2733

Senshii opened this issue Apr 25, 2019 · 0 comments · Fixed by #2735
Labels
Bug Addressing a bug
Projects

Comments

@Senshii
Copy link

Senshii commented Apr 25, 2019

Description

Hello,
I use web3 offline without a node connection. I have a problem with the signTransaction method (web3.eth.accounts.signTransaction). Nonce existence check in this method is not correct.

Expected behavior

Calling web3.eth.accounts.signTransaction with a nonce (even at 0) should return a signed transaction without trying to call the ethereum node.

Actual behavior

Calling web3.eth.accounts.signTransaction with a nonce at 0 will call the ethereum node to get the transactionCount

Steps to reproduce the behavior

1. Import `web3`
2. Try to sign a transaction like this:
     web3.eth.accounts
       .signTransaction(
         {
           gas: 1000000,
           nonce: 0,
           chainId,
           gasPrice,
           data,
         },
         account.privateKey,
       )
  1. You can see that your node is called with

{ jsonrpc: '2.0',
id: 1,
method: 'eth_getTransactionCount',
params: [ 'Address', 'latest' ] }

Versions

  • web3.js: 1.0.0-beta.52
  • nodejs: 10.15.3

I think the problem is at this line: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-eth-accounts/src/Accounts.js#L158
The if condition return false if nonce is set to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Addressing a bug
Projects
No open projects
1.0
  
Done
2 participants