with this code i want to call my token smartcontract's transfer function. as per my knowledge i have to add this ".transfer(address,amount)" to data field. am i correct? also i am using web3 0.20. in this version i have to use getData right? so that will be var dataforTx = mycontract.tranfer.getData(address,amount); then add that dataforTx to data field?
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' }** //how to get hex value of my dataforTx????????**var tx = new Tx(rawTx); tx.sign(privateKey);
var serializedTx = tx.serialize();
//console.log(serializedTx.toString('hex'));
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) { if (!err) console.log(hash); // "0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385" });
i am still not able to transfer token.it returns hash value but not reflecting any balance in other account. and if i use balanceOf then how to catch output of balanceOf function in sendRawTransaction