[Ethereum] Error: Returned error: invalid sender

transactionsweb3js

I'm trying to sign transaction and send it to remote node, but I keep getting this error:
UnhandledPromiseRejectionWarning: Error: Returned error: invalid sender

This is how I perform signing and then sending actions:

var Deployer = {
TxBuilder: function() {
    var signedTx;
    try{
        web3.eth.getTransactionCount(keyPair.address).then(function(res) {
            web3.eth.accounts.signTransaction({
                nonce: web3.utils.toHex(res + 1),
                from: keyPair.address,
                to: smartContractData.address,
                data: 'some encoded data here',
                gas: '4000000',
                gasPrice: web3.utils.toHex('5000000000'),
                gasLimit: web3.utils.toHex('4000000'),
                chainID: '2487'
            }, keyPair.privateKey).then(signedTx => {
                   //console.log(signedTx.rawTransaction);
                   web3.eth.sendSignedTransaction(signedTx.rawTransaction).on('receipt', console.log);
               });
        });
    } catch(error) {
        console.error('Error while sending signed tx: ' + error);
    }
}

};

Deployer.TxBuilder();

Here is account data, that I refer to in my code:

var keyPair = {
address: '0x413671Ef1633C4e31D07c4D36C92109792133C8a',
privateKey: ''

};

I'm able to sign the transaction, but I just can't send it, I tried what was described here: Invalid sender error on private chain but it didn't help as well.

I have balance in my account in custom ethers. I can deploy smart contracts and make calls / send transactions to any method in deployed smart contracts to the same private network from the very same account via MyEtherWallet, for instance. The problem is that I can't do it via web3.

I'm using:
– web3 1.0.0 36 beta

Any help with this is much appreciated, thank you!

Best Answer

This looks like an issue with version 2.0.0 of ethereumjs-tx:

https://github.com/ethereumjs/ethereumjs-tx/issues/165 16

You will need to construct your transaction like below:

const tx = new Tx(txObject, {chain:'ropsten', hardfork: 'petersburg'})