我正在尝试通过infura将rawTransactions发送到Ropsten网络。 这些是我在React Native项目中使用的库。
我已经为此苦苦挣扎了几个星期。请指教。 有人建议我将r,v,s实现到rawTransaction消息中。我不确定是否可以解决问题,如何获得r,v,s?
var count = web3.eth.getTransactionCount(fromAddress,'pending', (error, nounce) => {
console.log('This is the nouce'+ web3.toHex(nounce))
var data = _myContract.transfer.getData(toAddress, 10000);
var gasPrice = 1;
var gasLimit =3000000;
const chain_id =3;
const gas = 21000;
var rawTransaction = {
"from": fromAddress,
"nonce": web3.toHex(nounce),
"gasPrice": web3.toHex(gasPrice),
"gasLimit": web3.toHex(gasLimit),
"to": toAddress,
"value":'0x00',
"data": data,
"chainId": chain_id,
"gas":gas
};
var privKey = new Buffer('key', 'hex');
var tx = new Tx(rawTransaction);
tx.sign(privKey);
var serializedTx = tx.serialize();
console.log('RawTransaction :' + '0x' + serializedTx.toString('hex'))
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
console.log(hash);
else
console.log(err);
});
})