I want sign bep20 token using web3 but i get error this error
insufficient funds for gas * price + value: address ____ have 4960958883943891 want 69411784877494906285795002945479676105 (supplied gas 21000)
const Tx = require('ethereumjs-tx').Transaction
const { Web3 } = require('web3');
const newLocal = 'https://bsc-dataseed1.binance.org:443'
const web3 = new Web3(new Web3.providers.HttpProvider(newLocal));
const txObject = {
nonce:web3.utils.toHex(Number(txCount)),
to:addressTo,
value:web3.utils.toHex(web3.utils.toWei(balancetoSendToEther,'ether')),
gasLimit:web3.utils.toHex(21000),
gasPrice:web3.utils.toHex(web3.utils.toWei(gasPriceToEther,'gwei')),
maxPriorityFeePerGas: web3.utils.toWei("3", "gwei"),
maxFeePerGas: web3.utils.toWei("3", "gwei"),
common: {
customChain: {
name: 'custom-chain',
chainId: 56,
networkId: 56
}
}
}
// Sign the transaction
const tx = new Tx(txObject)
tx.sign(_private_key)
const serializedTransaction = tx.serialize()
const raw = '0x'+ serializedTransaction.toString('hex')
why gasprice is hight => 69411784877494906285795002945479676105
I finally managed to reduce the gasprice by changing the version of web3 to 1.7.5. Here is the code