Calling `web3.eth.sendSignedTransaction(data)` should succeed.
Calling `web3.eth.sendSignedTransaction(data)`
returns `error: {"code":-32000,"message":"invalid sender"}`.
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: {"code":-32000,"message":"invalid sender"}
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
chainlike thisvar tx = new Tx(rawTx, {'chain':'ropsten'});
This works 100%
Thanks.
Most helpful comment
@PaulRBerg If you want to use the version: 2.0.0, you should add extra parameter
chainlike this