[Ethereum] ropsten: insufficient funds for gas * price + value using web3


Im using "web3": "^1.0.0-beta.37"

And I want to understand How can I send rawTransaction

My code is:

const pk = 'xxxxxxx';
const rawTransaction = {
    "to": "0xa53709839ab6Da3ad9c1518Ed39a4a0fFCbA3684",
    "value": web3.utils.toWei('1', 'wei'),
    "gas": 2000000,
    "chainId": 3
let signedTx = await web3.eth.accounts.signTransaction(rawTransaction, pk).catch(console.dir);
let sendTx = await web3.eth.sendSignedTransaction(signedTx.rawTransaction).catch(console.error);

My account has 4Eth (on ropsten) and my httpProvider is ropsten (using infura)

but I get this error

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

I follow:


and then


Best Answer

Well, the message is saying that you don’t have funds. Here’s what you can do:

  1. Double check that the pk you are using to sign that transaction is actually the private key of the account with enough balance.

  2. Double check the web3 provider is actually pointing to the same network you have ethers in. Are you sure the infura node is connected to ropsten?

  3. Try to execute getBalance() for that account and verify the output is displaying correctly your balance

Related Topic