Ошибка:
Код: Выделить всё
Attempt 1 to create associated token account failed: 'solders.transaction.Transaction' object has no attribute 'recent_blockhash' and no __dict__ for setting new attributes
Код: Выделить всё
msg = Message([create_ata_ix], payer.pubkey())
tx_ata = await client.send_transaction(
Transaction([payer], msg, (await client.get_latest_blockhash()).value.blockhash),
opts=TxOpts(skip_preflight=True,
preflight_commitment=Confirmed)
)
await client.confirm_transaction(tx_ata.value, commitment="confirmed")
print("Associated token account created.")
print(f"Associated token account address: {
associated_token_account}")
break
else:
print("Associated token account already exists.")
print(f"Associated token account address: {
associated_token_account}")
break
except Exception as e:
print(f"Attempt {
ata_attempt + 1} to create associated token account failed: {str(e)}")
if ata_attempt < max_retries - 1:
wait_time = 2 ** ata_attempt
print(f"Retrying in {wait_time} seconds...")
await asyncio.sleep(wait_time)
else:
print(
"Max retries reached. Unable to create associated token account.")
return`
Заранее спасибо.
Пытался добавить недавний_блокхэш к транзакции и настроить процесс создания транзакции, но получил еще одну ошибку.
Код: Выделить всё
# Create the associated token account instruction
create_ata_ix = spl_token.create_associated_token_account(
payer=payer.pubkey(),
owner=payer.pubkey(),
mint=mint
)
# Construct the message and the transaction with the blockhash
msg = Message([create_ata_ix], payer.pubkey())
tx_ata = VersionedTransaction(
payer=payer,
message=msg,
recent_blockhash=recent_blockhash # Add the blockhash here
)
# Send the transaction
tx_hash = await client.send_transaction(tx_ata, payer, opts=TxOpts(skip_preflight=True, preflight_commitment=Confirmed))
await client.confirm_transaction(tx_hash.value, commitment="confirmed")
print("Associated token account created.")
print(f"Associated token account address: {associated_token_account}")
break
else:
print("Associated token account already exists.")
print(f"Associated token account address: {associated_token_account}")
break
except Exception as e:
print(f"Attempt {ata_attempt + 1} to create associated token account failed: {str(e)}")
if ata_attempt < max_retries - 1:
wait_time = 2 ** ata_attempt
print(f"Retrying in {wait_time} seconds...")
await asyncio.sleep(wait_time)
else:
print("Max retries reached. Unable to create associated token account.")
return
Код: Выделить всё
Attempt 1 to create associated token account failed: VersionedTransaction.__new__() got an unexpected keyword argument 'payer'
Подробнее здесь: https://stackoverflow.com/questions/792 ... ute-recent