在过去的几天里,我一直在尝试在以太坊测试网 Rinkeby 上发送一笔交易,无论我将 Gas 增加多少,都会不断收到此错误。
“未处理的拒绝错误:返回错误:内在气体太低”
我发送的数据是:
"0x7b22416e7377657273223a5b7b225175657374696f6e223a2231222c22416e73776572223a2234227d2c7b225175657374696f6e223a2232222c22416e73776572223a2234227d2c7b225175657374696f6e223a2233222c22416e73776572223a2234227d2c7b225175657374696f6e223a2234222c22416e73776572223a2234227d2c7b225175657374696f6e223a2235222c22416e73776572223a2234227d2c7b225175657374696f6e223a2236222c22416e73776572223a2234227d5d7d"
转换为十六进制后。
我在下面添加了我的代码。
var number = web3.eth.getTransactionCount(address).then(function(count) {
console.log("Count " + count);
var privateKey = new EthJS.Buffer.Buffer(privateKey, 'hex');
console.log(web3.utils.toHex(finalAnswers));
var rawTx = {
nonce: web3.utils.toHex(count),
to: '0xF1aA87F7058e5ABE561cCe8A466eE1CC17d69639',
value: 0,
data: web3.utils.toHex(finalAnswers),
gas: 50000,
gasPrice: web3.utils.toWei('300', 'gwei')
};
var tx = new EthJS.Tx(rawTx);
tx.sign(privateKey);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex')).on('receipt', console.log);
});
您收到此错误的原因是因为gasPrice
高于gasLimit
。您需要通过设置更高的值来分配更多的gasgasLimit
.
正如 @AdamKipris 在评论中建议的那样,你应该使用gasLimit:
代替gas:
建立交易时。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)