Hi!
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 keyPair = {
address: '0x413671Ef1633C4e31D07c4D36C92109792133C8a',
privateKey: '0x6ade95688cb8c16a6e6543505a995a3ad37fb93404189228d5f2ed690008a2ce' //also tried without prefix
};
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 for tx`,
gas: '4000000',
gasPrice: web3.utils.toHex('5000000000'),
gasLimit: web3.utils.toHex('4000000'),
chainID: '2487' // chain ID set to a genesis.json
//v: 28 also tried v: 27, v: chainID, v: chainID * 35 + 2
}, 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();
`
And here is the error I'm getting:
`
(node:31584) UnhandledPromiseRejectionWarning: Error: Returned error: invalid sender
at Object.ErrorResponse (/home/vlad/projects/TxSigner_Sender/node_modules/web3-core-helpers/src/errors.js:29:16)
at /home/vlad/projects/TxSigner_Sender/node_modules/web3-core-requestmanager/src/index.js:140:36
at XMLHttpRequest.request.onreadystatechange (/home/vlad/projects/TxSigner_Sender/node_modules/web3-providers-http/src/index.js:91:13)
at XMLHttpRequestEventTarget.dispatchEvent (/home/vlad/projects/TxSigner_Sender/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (/home/vlad/projects/TxSigner_Sender/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (/home/vlad/projects/TxSigner_Sender/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
at IncomingMessage.<anonymous> (/home/vlad/projects/TxSigner_Sender/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:31584) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:31584) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
`
I'm able to sign the transaction, but I just can't send it. Also I can call / send transaction to any method in any smart contract on the same private network from the very same account via MyEtherWallet (after connecting to the node of course). The problem is that I just can't do the same via web3.
I'm using:
- web3 1.0.0 36 beta
Any help with this is much appreciated, thank you!