chainstacklabs / pump-fun-bot

A fully functional pump.fun trading and sniping bot not relying on any 3rd party APIs
101 stars 49 forks source link

cannot convert 'Transaction' object to bytes #1

Closed creosmart closed 2 weeks ago

creosmart commented 1 month ago

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

akegaviar commented 1 month 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

AidHamza commented 1 month ago

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

creosmart commented 1 month ago

@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?

akegaviar commented 1 month ago

@creosmart I suggest you add logging to see at what the stage the issue is.

nickatnight commented 1 month ago

@creosmart I encountered this same issue. I fixed it by using solana version 0.34.0 instead of 0.35.0

akegaviar commented 1 month ago

Thanks for the help @nickatnight . I should have included requirements.txt right from the start but missed that and only added it yesterday.

creosmart commented 1 month ago

Thanks a lot @nickatnight, as a beginner I couldn't figure it out and it was doing my head in 😁

Avinaash7 commented 1 month ago

@creosmart I encountered this same issue. I fixed it by using solana version 0.34.0 instead of 0.35.0

Facing the same issue even in version 0.34.0

teletonn commented 1 month ago

There should be solana==0.34.3 in requirements.txt, or it will install 35 version thats not working.

smypmsa commented 1 month ago

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)
                    )
AidHamza commented 4 weeks ago

@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

tigermumu commented 3 weeks ago

It is worked @solana 0.34.0, and only this version

creosmart commented 3 weeks ago

The problem is in Transaction object imported from solana. It works fine if you replace it with the one from solders.transaction.

@smypmsa can you please provide the revised buy.py file? I was unable to replace the original code successfully.

bekov001 commented 2 weeks ago

what happened in 0.35.0 version? They destroyed everything