This question already has an answer here:

web3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/root@123", request_kwargs={'timeout': 60}))

when I used this then sendTransaction is not working . I have to use sendRawTransaction . I want to use this 2 addresses for sendRawTransaction 0x33e9d80d9209a00B3F953748Bd59D68b4c7c7B91 , 0x72f5445cd31D7B6dedBBCDD425A558aeEa4B3acE .

Now how could I use this ? Please help me out.

marked as duplicate by niksmac, Achala Dissanayake, Ismael, carver, Badr Bellaj Oct 4 '17 at 19:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

If you want to use sendrRawtTransaction you need pass the transaction signed and in raw bytes. The posts here and here will give a good understanding about the difference between the two methods.

I want to use this 2 addresses for sendRawtTransaction

0x33e9d80d9209a00B3F953748Bd59D68b4c7c7B91 , 0x72f5445cd31D7B6dedBBCDD425A558aeEa4B3acE .

Now how could I use this ?

To use sendRawTransaction,signing and getting the raw bytes can be done as explained here.

var Tx = require('ethereumjs-tx');
var privateKey = new Buffer('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109','hex')

var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000', 
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000', 
  value: '0x00', 
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
}

var tx = new Tx(rawTx);
tx.sign(privateKey);

var serializedTx = tx.serialize();

//console.log(serializedTx.toString('hex'));
//0xf889808609184e72a00082271094000000000000000000000000000000000000000080a47f74657374320000000000000000000000000000000000000000000000000000006000571ca08a8bbf888cfa37bbf0bb965423625641fc956967b81d12e23709cead01446075a01ce999b56a8a88504be365442ea61239198e23d1fce7d00fcfc5cd3b44b7215f

web3.eth.sendRawTransaction(serializedTx.toString('hex'), function(err, hash) {
  if (!err)
    console.log(hash); // "0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385"
});

And this question will also be useful.

Hope this helps!

Not the answer you're looking for? Browse other questions tagged or ask your own question.