3

When we are making any transaction then we need gas for every transaction so how much gas I fixed to making successful transactions because sometimes the transaction is successful, and sometimes it gives me an error:

Error: Returned error: insufficient funds for gas * price + value

exports.sendTransactions = (sender_account, to_account, p_key, value ) => {
  console.log("sendTRansactions", sender_account,  to_account , p_key , value );
  var admin = sender_account;
  var contract_address = to_account;
  var tx = {
    from: admin,
    to: contract_address,
    gas: 184000,
    data: "",
    value: value
  };
   return web3.eth.accounts.signTransaction(tx, p_key).then((hash) => {
     return web3.eth.sendSignedTransaction(hash.rawTransaction).then((receipt) => {
       return receipt
    }, (error) => {
      return error
      console.log(error);
      // reject(500);
    })
  }, (error) => {
    return error
    // reject(500);
  });
}
TylerH
  • 20,799
  • 66
  • 75
  • 101
Bablu Singh
  • 483
  • 4
  • 14
  • Does this answer your question? [Insufficient funds for gas\*price+value error](https://stackoverflow.com/questions/42970697/insufficient-funds-for-gaspricevalue-error) – TylerH May 05 '23 at 21:22

1 Answers1

2

I just made gas is in string example: gas: '184000',

and it working for me.

Bablu Singh
  • 483
  • 4
  • 14