0

I've seen many topics, but I've yet not solved my problem. Please, help me!

 var EthereumTx=require('ethereumjs-tx').Transaction
 const Web3=require('web3')
 const web3 = new Web3('https://rinkeby.infura.io/v3/85xxxxxxxxxxx2af25e829b8d9df')
 const account1='0xbd77caf08fe49d3f5aef6f83fc23b8d2129b468f'
 const main = async () => {
    const count = await web3.eth.getTransactionCount('0xxxxxxxxxxxxxxxf5aef6f83fc23b8d2129b468f');
    const nonce = web3.utils.toHex(count);
    const block = await web3.eth.getBlock('latest');

  const gasLimit = web3.utils.toHex(3000000)
  const gasPrice = web3.utils.toHex(22 * 1e9) // 5 gwei
 const privateKey = Buffer.from(
  'xxxxxxxxxxxxxxxxxxxxxxxxxx',
  'hex',
)

        const txParams = {
          from: "0xxxxxxxxxxxxxxxxxxxxxxxxxxxx9b468f",
          gasPrice: gasPrice,
          gasLimit: gasLimit,
          to: '0xxxxxxxxxxxxxxxxxxxxxxb91a04e',
          value: web3.utils.toHex(web3.utils.toWei('1','ether')),
          data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
         chainId: '0x03'

        }
// The second parameter is not necessary if these values are used
const tx = new EthereumTx(txParams, { chain: 'rinkeby', hardfork: 'petersburg' })
tx.sign(privateKey)
const serializedTx = tx.serialize()
    const raw ='0x'+serializedTx.toString('hex')
    // broadcast the trasnaction 

    web3.eth.sendSignedTransaction(raw,(err,txHash)=>{
      console.log('err:',err,'txHash:',txHash)
    })
 }

main();

I've got this error

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

4
  • 1
    For Rinkeby chainId is 4, not 3. Check private key is valid, after signing tx.getSenderAddress() should return the same as from if correct.
    – Ismael
    May 24 '20 at 2:35
  • Please share everything except for your Infura project ID and your private key (i.e., the value of the from field, the value of the to field, and the account address which you pass to getTransactionCount (which should be the same as the value of the from field)). May 24 '20 at 8:48
  • Do you have at least 1.066 ether in the account whose private key is xxxxxxxxxxxxxxxxxxxxxxxxxx? May 24 '20 at 8:52
  • If your account is the same used in the example then it has zero balance in rinkeby.
    – Ismael
    May 25 '20 at 5:24
0

change chainId to 4 , chek private key is true , and after signing private key enter tx.getSenderAddress() but is not working and yet error insufficient funds for gas * price + value

please help me :(

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.