@tevipo1542

Ошибка web3 gas price?

from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://mainnet.optimism.io'))

to_send = ''

gas_price = w3.eth.gas_price
for account in open("PrivateKey.txt"):
    account = account.strip().split(":")
    account[0] = Web3.toChecksumAddress(account[0].lower())
    print(account[0])
    balance = w3.eth.get_balance(account[0])
    if balance - (21000 * gas_price) > 0:
        tx = {
            'nonce': w3.eth.getTransactionCount(account[0]),
            'to': to_send,
            'value': balance - (21000 * gas_price),
            'gas': 21000,
            'gasPrice': gas_price,
            'chainId': 10,
        }
        signed_tx = w3.eth.account.signTransaction(tx, account[1])
        tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
        print(account[0], " - ", Web3.toHex(tx_hash))

Получаю ошибку ValueError: {'code': -32000, 'message': 'invalid transaction: insufficient funds for gas * price + value'}

Как фиксть?
  • Вопрос задан
  • 318 просмотров
Пригласить эксперта
Ответы на вопрос 1
sheerluck
@sheerluck
У вас недостаточно денег для комиссия + value. https://habr.com/ru/post/336770/
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы