現在、生のイーサリアム トランザクションを作成してブロードキャストする関数を作成しています。生のトランザクションを正常に生成できますが、それをネットワークに送信しようとすると処理されません。以下は私のコードです:
function createRawTransacton() {
var privateKey = new Buffer('xxx', 'hex')
var rawTx = {
nonce: 'CX350',
gasPrice: 'C350',
gasLimit: '0x3d0900',
to: '0xc5622be5861b7200cbace14e28b98c4ab77bd9b4',
value: 'CX350',
data: '0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f'
}
var tx = new Tx(rawTx)
tx.sign(privateKey)
var serializedTx = tx.serialize()
console.log(serializedTx.toString('hex'))
broadCastTx(serializedTx.toString('hex'))
}
およびブロードキャストするコード:
function broadCastTx(hex) {
var query = "https://testnet.etherscan.io/api?module=proxy&action=eth_sendRawTransaction&hex="
query += hex;
query += "&apikey=xxx'"
request.get(query, (err, data) => {
console.log(data.body)
})
}