I am trying to create a transaction by sending 1 ether from one account to another. Currently, I'm running a local fully-synched parity node. It's running on the Volta test network of EWF (Energy Web Foundation). It's actually possible connecting to that node by Metamask and sending some Ether, but whenever I try that with the web3js which runs in a nodejs app, the parity node gives the following warning/output:
2019-10-25 00:56:50 jsonrpc-eventloop-0 TRACE own_tx Importing transaction: PendingTransaction { transaction: SignedTransaction { transaction: UnverifiedTransaction { unsigned: Transaction { nonce: 1, gas_price: 60000000000, gas: 21000, action: Call(0x2fa24fee2643d577d2859e90bc6d9df0e952034c), value: 1000000000000000000, data: [] }, v: 37, r: 44380982720866416681786190614497685349697533052419104293476368619223783280954, s: 3058706309566473993642661190954381582008760336148306221085742371338506386965, hash: 0x31b4f889f5f10e08b9f10c87f953c9dfded5d0ed1983815c3b1b837700f43702 }, sender: 0x0b9b5323069e9f9fb438e89196b121f3d40fd56e, public: Some(0xa3fc6a484716b844f18cef0039444a3188a295811f133324288cb963f3e5a21dd6ee19c91e42fa745b45a3cf876ff04e0fd1d060ccfe1dab9b1d608dda4c3733) }, condition: None }
2019-10-25 00:56:50 jsonrpc-eventloop-0 DEBUG own_tx Imported to the pool (hash 0x31b4f889f5f10e08b9f10c87f953c9dfded5d0ed1983815c3b1b837700f43702)
2019-10-25 00:56:50 jsonrpc-eventloop-0 WARN own_tx Transaction marked invalid (hash 0x31b4f889f5f10e08b9f10c87f953c9dfded5d0ed1983815c3b1b837700f43702)
When I checked the balance of the accounts, nothing has happened. I've tried to increase gasPrice, adding a 'from' key/value pair to txObject, etc. I have also started parity node with --no-persistent-txqueue
so that it doesn't cache too many of transactions, as it's suggested here. But that didn't change anything, either. So I still get the same error and transaction doesn't go through. What is causing this problem and how can I solve it?
web3.eth.getTransactionCount(from, (err, txCount) => {
const txObject = {
nonce: web3.utils.toHex(txCount),
from: from,
to: to,
value: web3.utils.toHex(web3.utils.toWei(val, 'ether')),
gas: web3.utils.toHex(21000),
gasPrice: web3.utils.toHex(web3.utils.toWei('60', 'gwei'))
}
// Sign the transaction
const tx = new Tx(txObject);
tx.sign(pk);
const serializedTx = tx.serialize();
const raw = '0x' + serializedTx.toString('hex');
// Broadchast the transaction to the network
web3.eth.sendSignedTransaction(raw, (err, txHash) => {
if (txHash === undefined) {
res.render('sendTransaction', {
txSuccess: 0,
blockHash: 'Hash Undefined'
});
res.end();;
} else {
res.render('sendTransaction', {
txSuccess: 1,
blockHash: txHash,
});
res.end();;
}
});
});
Any suggestion is welcome, Thanks!