I am trying to send some test ether on Ropsten network using Infura but I can not make a transaction. Code works locally with testrpc but not with Infura

var Web3 = require('web3');
var util = require('ethereumjs-util');
var tx = require('ethereumjs-tx');
var lightwallet = require('eth-lightwallet');
var txutils = lightwallet.txutils;

var web3 = new Web3(
    new Web3.providers.HttpProvider('https://ropsten.infura.io/<token>')
    //new Web3.providers.HttpProvider('http://localhost:8545')

var address = '0xadaD904F70ec8323fEd1734614d78D2145222322';
var address2 = '0x5858599f16c46fa33238313A412eE9f0491EBef3';
var key = '<KEY>';
var key2 = '<KEY>';
var amount = web3.toWei(1, "ether");
var balance = web3.eth.getBalance(address);

var value = web3.fromWei(balance, 'ether');


function sendRaw(rawTx) {
    var privateKey = new Buffer(key, 'hex');
    var transaction = new tx(rawTx);
    var serializedTx = transaction.serialize().toString('hex');
        '0x' + serializedTx, function(err, result) {
            if(err) {
            } else {

var rawTx = {
    nonce: web3.toHex(web3.eth.getTransactionCount(address)),
    gasLimit: web3.toHex(21000),
    to: address2,
    value: web3.toHex(web3.toBigNumber(amount))



As you can notice I am logging ether on address but no matter how many times I send the transaction it stays eq to 1eth.

Any ideas what I am doing wrong?


3 Answers 3


This looks mostly correct, but there are a couple optional tx parameters that might make the difference:

  // EIP 155 chainId - mainnet: 1, ropsten: 3
  chainId: 3,
  gasPrice: "0x9184e72a000", // 10000000000000

Also, the nonce may need to be converted to hexadecimal. The getTransactionCount method returns a javascript number, so you might need to convert that to hex first.

I'd recommend also logging the parameters before you send it out. If you're connecting to a node that is not synchronized, your nonce could be wrong, and that would also fail these transactions.

I see you got one tx out, so that makes me think a wrong nonce could be blocking you. https://testnet.etherscan.io/tx/0x17c6e7e318a181cc729207ebe2bc203b4df71657b845aaf551892f20de42bc62

  • It was gasPrice actually. It seems I need to specify the price. I convert nonce to hext with web3.toHex so that was ok I guess.
    – wonglik
    Commented Feb 20, 2017 at 6:56
  • I don't think its the nonce, since his getting the value from gettransactioncount(). If it's a gas issue, then it will just take longer when its low. Check if the chain value is properly is correct, if its using ropster network, should not be assigned something else like mainnet.
    – winux
    Commented Apr 23, 2020 at 11:19

Can you try printing out the raw serialized transaction and sending it to ropsten directly with CURL?


Do you get a txid back?


We experienced a similar issue with an Infura node not being in sync. Since there are multiple Infura nodes behind their load balancer, our getTransactionCount was hitting an out of sync node and returning an incorrect number. Just wanted to flag it as this may save you some time debugging in future situations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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