Categories
Cryptocurrency Ethereum Mastering Development

problem help me gas * price + value

i see all topic , but yet not slove my problem .
please help me

<pre>

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();

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

Leave a Reply

Your email address will not be published. Required fields are marked *