web3-eth icon indicating copy to clipboard operation
web3-eth copied to clipboard

How to send signed transaction with private key on ruby on rails

Open noydarly opened this issue 6 years ago • 2 comments

Hi everyone. I am going to send transaction with my private key using web3-eth gem. But i can't find correct solution anywhere. Please help me! Best regards!

noydarly avatar Aug 06 '18 04:08 noydarly

I can do it with nodejs and python. But i want do it with ruby on rails. for example I can find this solution in nodejs var count = web3.eth.getTransactionCount("0x26..."); var abiArray = JSON.parse(fs.readFileSync('mycoin.json', 'utf-8')); var contractAddress = "0x8..."; var contract = web3.eth.contract(abiArray).at(contractAddress); var rawTransaction = { "from": "0x26...", "nonce": web3.toHex(count), "gasPrice": "0x04e3b29200", "gasLimit": "0x7458", "to": contractAddress, "value": "0x0", "data": contract.transfer.getData("0xCb...", 10, {from: "0x26..."}), "chainId": 0x03 };

var privKey = new Buffer('fc3...', 'hex'); var tx = new Tx(rawTransaction);

tx.sign(privKey); var serializedTx = tx.serialize();

web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) { if (!err) console.log(hash); else console.log(err); }); How can i do it in ruby on rails? Please help me.

noydarly avatar Aug 06 '18 04:08 noydarly

Any update on this?

wQwRtaufxJw7UFLCXzXz avatar Aug 10 '18 07:08 wQwRtaufxJw7UFLCXzXz