im getting this error while trying to send ethereum using my local geth node.
JavaScript
x
2
1
ValueError: {'code': -32000, 'message': 'insufficient funds for gas * price + value'}
2
here is how i build the tx
JavaScript
1
23
23
1
from web3 import Web3
2
3
w3 = Web3(Web3.HTTPProvider("http://localhost:8545"))
4
5
amount = 0.01
6
from_address = "0xF2........."
7
private_key = "cf.........."
8
address_to = "0x..."
9
nonce = w3.eth.getTransactionCount(from_address)
10
11
tx = {
12
'from': from_address,
13
'to': address_to,
14
'value': w3.toWei(amount, 'ether'),
15
'gas': 21000,
16
'gasPrice': w3.eth.gas_price,
17
'nonce': nonce,
18
'chainId': 1
19
}
20
signed_txn = w3.eth.account.sign_transaction(tx, private_key=private_key)
21
send = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
22
txid = send.hex()
23
My ethereum account has more than 2 ETH available What am I doing wrong?
Advertisement
Answer
The node error does not lie, so the node does not think you have 2 ETH available.
You can easily check with web3.eth.getBalance()
how much you have available.