blockchain - 使用 ethereumjs-tx 发送签名交易时如何修复无效发件人错误?
问题描述
尝试发送签名交易时收到无效发件人。这是错误:
Uncaught (in promise) Error: Returned error: invalid sender
这是代码:
var privateKey = Buffer.from('private key without 0x', 'hex');
var rawTx = {
nonce: await web3.utils.toHex(web3.eth.getTransactionCount(account1)),
to: account2,
value: web3.utils.toHex(web3.utils.toWei('1', 'ether')),
gasLimit: web3.utils.toHex(21000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei'))
}
var tx = new Transaction(rawTx, {'chain':'ropsten'});
tx.sign(privateKey);
var serializedTx = tx.serialize();
console.log('serializedTx', serializedTx)
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);
可能是什么问题呢?
解决方案
推荐阅读
- kubernetes - 如何找到 kubectl 支持的给定资源类型的字段选择器列表?
- java - 如何在java中传递aws iot x.509证书路径
- php - Ajax 请求在页面加载然后刷新时不起作用,但在单击指向同一页面的链接后会起作用
- reactjs - 如何仅在 firebaseAuthIsReady 时返回组件
- c++ - 如何从右到左展开参数包
- computer-vision - 从 imagenet 下载数据
- python - AttributeError:“str”对象没有属性“detect_intent”
- swift - 我正在做一个发布请求,我想在其中输入一个问题,并通过发布请求获得最常见的答案
- xsd - 将antlr语法转换为其他格式(即xsd、dtd)
- powershell - 需要删除选定的访问权限