Подключайтесь, используя все необходимые ключи — рыночный адрес, закрытый ключ и т. д.
Бот подключается, совершает сделки, но не возвращается прибыль в фантомный кошелек.
Основная проблема заключается в этой части:
Код: Выделить всё
def transfer_to_wallet(self, amount, retries=3):
try:
# Create transfer transaction
transaction = Transaction().add(
transfer(TransferParams(
from_pubkey=public_key,
to_pubkey=main_wallet_address,
lamports=int(amount * 1e9) # Convert SOL to lamports
))
)
# Send transaction and handle response
response = client.send_transaction(transaction, keypair)
# Check for transaction confirmation
if 'result' in response:
signature = response['result']
self.log_message(f"Transfer initiated with signature: {signature}")
# Poll for confirmation
confirmed = False
for attempt in range(10): # Check up to 10 times
confirmation = client.get_confirmed_transaction(signature)
if confirmation.get('result'):
confirmed = True
break
time.sleep(2) # Wait a bit before the next check
# Final confirmation message
if confirmed:
self.log_message(f"Transferred {amount} SOL to wallet, transaction confirmed with signature: {signature}")
else:
self.log_message(f"Transfer failed: Transaction not confirmed within timeout.")
else:
error_message = response.get('error', 'Unknown error')
self.log_message(f"Transfer failed with error: {error_message}")
except Exception as e:
# Retry mechanism
if retries > 0:
self.log_message(f"Transfer failed. Retrying... ({retries} retries left)")
time.sleep(2)
self.transfer_to_wallet(amount, retries - 1)
else:
self.log_message(f"Failed to transfer profits to wallet after retries: {e}")
У меня несколько вопросов :
Какие версии solana и pyserum совместимы? (Я использую solana 0.28.0 и pyserum 0.5.0a0). Обновление до solana 0.35.0 создает проблемы с совместимостью.
Какой еще метод мне следует использовать для перевода средств со счета бота обратно в фантомный кошелек?
Большое спасибо за ваше время. п>
Подробнее здесь: https://stackoverflow.com/questions/791 ... tion-error