I'm facing a gas issue on rinkeby network on sendRawTransaction.

Tested with various gas value to experiment and getting either insufficient funds for gas * price + value or exceeds block gas limit.

Some more info: Gas Estimate: 32872 Balance: 1100000 Gwei gas: 87200

Any suggestions or anybody faced similar issue?

My code here: https://gist.github.com/anistark/2daf9295a4d5a03cb405ff5a47924b32


From your code, you are checking the balance of an address and creating a new private key to sign the raw transaction.

// Original balance

let existingBalance = web3.fromWei(web3.eth.getBalance(accountAddress), balanceUnit).toString();
console.log('existingBalance:', existingBalance, balanceUnit);

// New account

let seedPhrase = lightwallet.keystore.generateRandomSeed();

    password: accountKey,
    seedPhrase: seedPhrase,
    hdPathString: "m/0'/0'/0'"
}, function (err, ks) {
    ks.keyFromPassword(accountKey, function (err, pwDerivedKey) {

        // Sign with new private key

        var tx = new Tx(rawTx);
        var privateKey = new Buffer(pwDerivedKey, 'hex')

The new private key is unrelated to the original address. And it will have zero balance unless funded explicitely.

  • Oh damn! Yes you are right. Could you also mention how to explicitly specify the private key from the keystore? – Ani Dec 6 '18 at 17:56
  • 1
    You do not want the private key from lightwallet, but from your accountAddress. – Ismael Dec 6 '18 at 18:55

Based on the info you mentioned:

Transaction gas limit : 87 200 gas units
Account balance: 1 100 000 wei

The Rinkeby network has the following properties

Gas Price: 1 000 000 wei (1 gwei)
Block gas limit: 7 129 048 gas units

It means for this particular transaction, it will cost in transaction fees: gas * gasPrice = 87 200 * 1 000 000 = 87 200 000 000 wei

However you account only has 1 100 000 wei, That why you get insufficient funds for gas * price + value.

For the other exception exceeds block gas limit, I think you put a gas linit higher than the block gas limit of the RunkeBy network.

  • It's 1100000 Gwei. My appologies for not mentioning before. Updated now. – Ani Dec 4 '18 at 10:06
  • What is the gasPrice (1gwei or more) ? the gasEstimate is not expressed in gwei but in gas units. Can you send me your account address – Greg Jeanmart Dec 4 '18 at 10:12
  • Hi Greg, It's 1 Gwei. I tested the same on remix browser as well. Here's my account address: 0x1a9ef715446cf878e04fff7347202cbc4c7ed5e8 – Ani Dec 4 '18 at 10:13

Your Answer

