我经营甘纳奇、松露和面膜。如果运行下面的代码,就会得到this.web3.eth.sendSignedTransaction()函数上的一个错误:
编辑:将我的代码更改为..然而,错误仍然没有改变。
const encoded_tx = this.contract.methods.createCountry("NL", 100, 100, 100000000, this.account).encodeABI();
const nonce = await this.web3.eth.getBlockTransactionCount(this.account);
const rawTx = {
nonce: this.utils.toHex(nonce),
gasLimit: this.utils.toHex(3000000),
gasPrice: this.utils.toHex(this.utils.toWei('20', 'gwei')),
data: encoded_tx,
from: this.account,
to: this.contractAddress
};
let tx = new Tx(rawTx);
tx.sign(this.pvtKey);
let serializedTx = tx.serialize();
this.web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);错误如下:
index.js:2178 Error: Returned error: {"id":6,"jsonrpc":"2.0","error":{"code":-32603}}
at Object.ErrorResponse (errors.js:29)我完全不知道该去哪里看看,感觉好像我什么都试过了,这可能和我和元问题有关联这一事实有关吗?当我试图使用eth.method.send()通过元问询发送此事务时,事务不会给出错误,并且会按照预期的行为。
发布于 2018-05-18 14:16:58
要获得现在的信息,您必须调用web3.eth.getTransactionCount,而不是getBlockTransactionCount。
要调试使用ganache的交互,您可以从ganache-cli --verbose开始,它将显示客户机之间的交互,一个ganache,并显示有关事务的更多细节。
https://ethereum.stackexchange.com/questions/48807
复制相似问题