I am using ethereumJs and web3.js to send erc20 tokens from one account to another account.I am able to get the hash of transaction, but cant see any transaction details on the etherscan.

var Web3 = require('web3');
var express = require('express');

var router = express.Router();
var fs    = require("fs");
var EthereumTx = require('ethereumjs-tx');
var crypto = require('crypto');
var secp256k1 = require('secp256k1');
var keccak =  require("keccak");

router.get('/', (req, res, next) => {

if ( typeof web3 !== 'undefined' && typeof web3 !== undefined) { 
    web3 = new Web3(web3.currentProvider);


   web3 =  new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/tPNyqnWI32IepQh2lrMf"));
   var count = web3.eth.getTransactionCount("0xD8d9e3fE93315b8ce838E39c4696438A8d8E66F3");
var abiArray = JSON.parse(fs.readFileSync('./public/mycoin.json', 'utf-8'));
var contractAddress = "0x9A48831A220c793ed4CcF0dCbD5390fB56EF9B91";
var contract = web3.eth.contract(abiArray).at(contractAddress);
   var number =  web3.eth.blockNumber;
   var rawTransaction = {
    "from": "0x95297713bdb43515420d9662a88516219085bb8a",
    "nonce": "0x001",
    "gasPrice": "0x9184e72a000",
    "gasLimit": "0x7458",
    "to": "0xDED54CC5f578Aa39c1083dbe16D68a28C776cA02",
    "value": "0x012",
    "data": contract.transfer.getData("0x9A48831A220c793ed4CcF0dCbD5390fB56EF9B91", 10, {from: "0xD8d9e3fE93315b8ce838E39c4696438A8d8E66F3"}),
    "chainId": "0x04"

var privKey = new Buffer('9e37167fd8b807a3805e41e34e07dd5472512ec568878c0a08c49cec0c5f9a4b', 'hex');
var tx = new EthereumTx(rawTransaction);

var serializedTx = tx.serialize();
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
     if (!err) { 



module.exports = router;

I am also broadcasting the trx hash to the network but getting an error----rlp: value size exceeds available input length Trx hash : 0xf614784bd9b375e1e4d6486880deb50a829b1a229620e80b16f5befe1c9ab4a0


It appears you have backward how transfer and to should behave.

var rawTransaction = {
    "from": "0x2222...",             // <-- Address owner tokens
    "nonce": "0x..",                 // <-- eth.getTransactionCount(from)
    "gasPrice": "0x9184e72a000",
    "gasLimit": "0x7458",           // <-- Might be low, try 90k = 0x015f90
    "to": "0x4444...",              // <-- Token address
    "value": "0x00",                // <-- Most tokens require value to be zero
    "data": contract.transfer.getData("0x999999...", 10),   // <-- Recipienet
    "chainId": "0x04"

To calculate the amount of token take into account the decimals. If decimals is 5, and you want to transfer 2 tokens the value is 200000. The more common value is 18 decimals, to send 11 tokens you need to calculate 11 * 10**18.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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