Closed creosmart closed 2 weeks ago
That's most likely due to the mismatch between the data you received from blockSubscribe
and the chain data. What this means ultimately is you need to increase the cooldown period to allow the chain data to catch up from the moment you receive it over blockSubscribe
and have the actual chain data. See the relevant issue https://github.com/anza-xyz/agave/issues/3074
As @akegaviar mentioned, sleep is a workaround, for my case, I kind of decoupled the logic, and separated the buy event, instead of waiting, you can rerun with retries till the expected result is satisfied. It had a great impact on the bot results
@akegaviar I increased the cooldown to 120 await asyncio.sleep(120)
but still getting the same error, any suggestions? @AidHamza I was hoping to be one of the first buyers of the token, can this be achieved with the logic you mentioned?
@creosmart I suggest you add logging to see at what the stage the issue is.
@creosmart I encountered this same issue. I fixed it by using solana
version 0.34.0
instead of 0.35.0
Thanks for the help @nickatnight . I should have included requirements.txt right from the start but missed that and only added it yesterday.
Thanks a lot @nickatnight, as a beginner I couldn't figure it out and it was doing my head in 😁
@creosmart I encountered this same issue. I fixed it by using
solana
version0.34.0
instead of0.35.0
Facing the same issue even in version 0.34.0
There should be solana==0.34.3 in requirements.txt, or it will install 35 version thats not working.
The problem is in Transaction
object imported from solana
. It works fine if you replace it with the one from solders.transaction
.
For example, the transaction for ATA creation will look like this:
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")
The transaction for buying a token (with the set_compute_unit_price
instruction to speed up its landing):
msg = Message([set_compute_unit_price(1_000), buy_ix], payer.pubkey())
tx_buy = await client.send_transaction(
Transaction([payer], msg, (await client.get_latest_blockhash()).value.blockhash),
opts=TxOpts(skip_preflight=True, preflight_commitment=Confirmed)
)
@akegaviar I increased the cooldown to 120
await asyncio.sleep(120)
but still getting the same error, any suggestions? @AidHamza I was hoping to be one of the first buyers of the token, can this be achieved with the logic you mentioned?
No guarantee that you can be the first one buying, it depends on so many factor, including the used node, latency, tasking the operations needed will just make things simpler, trackable, and gives you a better observability. Also easy to scale your operations if you wish to try multiple strategies and study the result
It is worked @solana 0.34.0, and only this version
The problem is in
Transaction
object imported fromsolana
. It works fine if you replace it with the one fromsolders.transaction
.
@smypmsa can you please provide the revised buy.py file? I was unable to replace the original code successfully.
what happened in 0.35.0 version? They destroyed everything
Hello, seems there's an error when running trade.py:
"Attempt 1 to create associated token account failed: cannot convert 'Transaction' object to bytes"
Thanks