Web3.js: sendSignedTransaction() error: invalid sender

Created on 27 Jun 2019  Â·  10Comments  Â·  Source: ChainSafe/web3.js

Description

Expected behavior

Calling `web3.eth.sendSignedTransaction(data)` should succeed.

Actual behavior

Calling `web3.eth.sendSignedTransaction(data)` 
returns `error: {"code":-32000,"message":"invalid sender"}`.

Steps to reproduce the behavior

const Tx = require('ethereumjs-tx');
const privateKey = new Buffer('e33xxxxc0fd109', 'hex')

const rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

const tx = new Tx(rawTx);
tx.sign(privateKey);

const serializedTx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);

Error Logs

error: {"code":-32000,"message":"invalid sender"}

Versions

  • web3.js: 1.0.0-beta.55
  • nodejs: v11.10.1
  • browser: Chrome

Most helpful comment

@PaulRBerg If you want to use the version: 2.0.0, you should add extra parameter chain like this

var tx = new Tx(rawTx, {'chain':'ropsten'});

All 10 comments

But this is not a bug of web3.js, it is due to the package ethereumjs-tx at the version 2.0.0, if you use the version 1.3.7, it will not have this error.

Besides above, I can not get anything from Promise Event receipt, does that means transactionHash now?

I am having issues with receipt as well. Keeps on waiting. Works with version beta 1.0.0-beta.36.

@shumailxyz When I try to use a lower version: 1.0.0-beta.36, I can get a log with .on("receipt", …

Ohhh, I find a similar issue that mentions the event receipt: #2601

I can also confirm that ethereumjs-tx version 2.0.0 is broken:

error: {"code":-32000,"message":"invalid sender"}

Reverting to 1.3.7 fixes the problem.

@PaulRBerg If you want to use the version: 2.0.0, you should add extra parameter chain like this

var tx = new Tx(rawTx, {'chain':'ropsten'});

I've closed this because your problem is related to the ethereumjs-tx package.

confirmed v1.3.7 works.

@PaulRBerg If you want to use the version: 2.0.0, you should add extra parameter chain like this

var tx = new Tx(rawTx, {'chain':'ropsten'});

This works 100%

Thanks.

Was this page helpful?
0 / 5 - 0 ratings