4

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!

16
  • What is the value of keyPair.address? Nov 5 '18 at 14:04
  • @goodvibration, it is a simple object with test keypair for private network deployed on a remote node. Value of the field is 0x413671Ef1633C4e31D07c4D36C92109792133C8a
    – Vlad
    Nov 5 '18 at 14:07
  • try to also add the parameter v: 2487 * 2 + 35 to the tx to be signed. Nov 5 '18 at 14:16
  • @TudorConstantin thanks, tried that, but the error still remains the same
    – Vlad
    Nov 5 '18 at 14:19
  • How did you configure the private network? Nov 5 '18 at 14:29
3

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'})
0

Like Shahid said, it has to do with an issue with 2.0.0 of ethereumjs-tx

Note that the hardfork property is optional.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.