Blockchain 为什么事务被标记为无效?

Blockchain 为什么事务被标记为无效?,blockchain,ethereum,web3js,parity,Blockchain,Ethereum,Web3js,Parity,我试图通过从一个帐户向另一个帐户发送1以太来创建事务。目前,我正在运行一个本地完全同步的奇偶校验节点。它在EWF(能源网络基金会)的Volta测试网络上运行。实际上,可以通过Metamask连接到该节点并发送一些以太,但每当我尝试使用在nodejs应用程序中运行的web3js时,奇偶校验节点会给出以下警告/输出: 2019-10-25 00:56:50 jsonrpc-eventloop-0 TRACE own_tx Importing transaction: PendingTransac

我试图通过从一个帐户向另一个帐户发送1以太来创建事务。目前,我正在运行一个本地完全同步的奇偶校验节点。它在EWF(能源网络基金会)的Volta测试网络上运行。实际上,可以通过Metamask连接到该节点并发送一些以太,但每当我尝试使用在nodejs应用程序中运行的web3js时,奇偶校验节点会给出以下警告/输出:

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)
当我检查账目余额时,什么也没发生。我尝试增加gasPrice,向txObject添加一个“from”键/值对,等等。我还使用
启动了奇偶校验节点——没有持久的txqueue
,这样它就不会像建议的那样缓存太多的事务。但这也没有改变任何事情。所以我仍然得到相同的错误,并且事务没有通过。造成此问题的原因是什么?如何解决

    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();;
            }
        });
    });

欢迎任何建议,
谢谢

代码看起来很好,所以它一定很小,很接近

  • web3.eth中的
    error
    对象包含什么。sendSignedTransaction
    回调
  • 检查您的
    nonce
    ,确保它尚未被使用。显示来自发件人地址的一些事务,其中“4”是
    nonce的下一个值
  • 尝试通过JavaScript生成原始事务,并通过命令行手动广播它