rckprtr/pumpdotfun-sdk

Sell results: { success: false, error: 'Transaction failed' }

Opened this issue · 13 comments

i tried to use the sdk to create a sell function to sell a random token on pumpfun thats in my wallet , the tx goes through, prints out the signature tx as solscan link , however, it throws success as false and error as tx failed , which will lead to attempted retries for selling. is it sdks handling of succes as false when the tx is confirmed or im doing something wrong ????
Heres THE LOGS ...
Seller SOL balance before sell: 0.054742152 SOL
Seller SPL balance before sell: 29166.843056 tokens
sig: https://solscan.io/tx/56AG7V89fHNeN4cwDaXJiSZMuNaaaXJ4zZ2wFRzkGK3UFcKX4tbKe2xdn74bWqMLE6dQKe6moKY6Hotc9gp6pFKq
Sell results: { success: false, error: 'Transaction failed' }
Transaction confirmed. View it on Solscan: https://solscan.io/tx/undefined
Seller SOL balance after sell: 0.055481914 SOL
Seller SPL balance after sell: 2.916685 tokens.
lance after sell: 2.916685 tokens

I also encountered this situation. In fact, the transaction was successful. I ran it in the Chrome browser, and there were always some WebSocket connection errors: chunk-KCB7GPR7.js?v=ff63d6b4:8850 WebSocket connection to 'wss://go.getblock.io/*****' failed:

我也遇到了这种情况,其实交易是成功的,我在Chrome浏览器里运行了一下,总是出现一些WebSocket连接错误:chunk-KCB7GPR7.js?v=ff63d6b4:8850 WebSocket connection to 'wss://go.getblock.io/*****' failed:

Does this connection also need to support WebSocket?
const provider = new AnchorProvider(connection, wallet, {
preflightCommitment: 'confirmed',
});

i think , its the handling if sugnature part from the sdk . The sdk automatically prints signature of tx as solscan link , and if you want to check the signature for success or failure of the transaction, the signature isnt the signature alone but the solscan link , which is invalid signature to parse .

Hmm, it may be websockets + Anchor. Ill take a look.

Any input will help:

Just to make sure its reporting the TX failed but it was a success?

yes , the tx is successful , the signature with solscan link is also valid and can be visited to see tx was finalized (mostly, and sometimes slippage error), the sol and slp balance before and after sell is also correct (just to check if the sell function of sdk was working ). I wanted to verify if the tx was successful, and implement retries if it failed ,but to my surprise, the sell result was identified as false (even when its true), which led to retries because the loop assumed the tx had failed .

ALSO , tried making the buy function that buys pumpfun tokens , got the same error. The buy works with valid solscan link containing the signature, but buy results return success:false and error: transaction failed.

Same issue.
Success returns false when it is successful.

yes , the tx is successful , the signature with solscan link is also valid and can be visited to see tx was finalized (mostly, and sometimes slippage error), the sol and slp balance before and after sell is also correct (just to check if the sell function of sdk was working ). I wanted to verify if the tx was successful, and implement retries if it failed ,but to my surprise, the sell result was identified as false (even when its true), which led to retries because the loop assumed the tx had failed .

ALSO , tried making the buy function that buys pumpfun tokens , got the same error. The buy works with valid solscan link containing the signature, but buy results return success:false and error: transaction failed.

If you got time, can you show me how you are setting up your connection?

const provider = getProvider(wallet);
const sdk = new PumpFunSDK(provider);
const connection = provider.connection;

const mintAddress = new PublicKey('DrbLgXTPZ31P17Tt11pYngkbZ4SUEXJHU2xBPDenpump');

await printSOLBalance(connection, sellerKeypair.publicKey, 'Seller SOL balance before sell');
await printSPLBalance(sdk, mintAddress, sellerKeypair.publicKey, 'Seller SPL balance before sell');

const currentSolBalance = await connection.getBalance(sellerKeypair.publicKey);
if (currentSolBalance < 0.004 * LAMPORTS_PER_SOL) {
throw new Error('Insufficient SOL balance. Please fund the seller account with at least 0.004 SOL.');
}

await sellToken(sdk, sellerKeypair, mintAddress);

await printSOLBalance(connection, sellerKeypair.publicKey, 'Seller SOL balance after sell');
await printSPLBalance(sdk, mintAddress, sellerKeypair.publicKey, 'Seller SPL balance after sell');

Any update on this?
@rckprtr

Any update on this? @rckprtr

My assumption is its a mix up between expected commit levels where the transaction may not exist yet relative to those levels. Im trying out different scenarios and will update it. You can also just copy the buy logic and have your own way of customizing the tx handling, but Im going to see if I can pull it apart a bit and see what the scenario is.

Thank you, @oneplusfive555 im checking it out.

hi @rckprtr
Same issue with buy transaction

error: SendTransactionError: Simulation failed.
Message: Transaction simulation failed: Blockhash not found.

sig: https://solscan.io/tx/35PmNWX1e6aJGZxoN1Pug66XaT2MjnwnMxG9vJL9uMS2mp6jGqpDVCz2nJqbdCmEPpH8wwTFS4Lt4JYpm4VQQVfz
TransactionExpiredBlockheightExceededError: Signature 35PmNWX1e6aJGZxoN1Pug66XaT2MjnwnMxG9vJL9uMS2mp6jGqpDVCz2nJqbdCmEPpH8wwTFS4Lt4JYpm4VQQVfz has expired: block height exceeded.

@rckprtr i dont know if it helps other, but i fixed the issue by implementing a delay of 5 sec to check the success of tx results (i assumed the blockchian would take 5-8 seconds to finalize the tx). I would send the buy/ sell tx , wait 5 seconds to fetch the slp balance or token account creation after function excution (because if tx is successful, the associated token account must be created or slp balance must be there in the wallet ). Instead of relying on if success.results is true/false , i now rely on if slp balance>0 or if token account is present after 5 sec of sending tx. if true buy/sell is success else failed with reties implemented.

heres one log of successful tx ..
Mint address 2QuN9CLy6cyURnrLffg79WXQcquwr2iprLmzYxKupump passed all checks. Initializing buy...
2024-07-25T22:18:13.737Z [INFO]: Buyer SOL balance before purchase: 0.025859356 SOL
sig: https://solscan.io/tx/5SdX1LL98HgyLi9S2Yen7i3pcnzj5w9K3Bg6TqAZVDErX98Xu6Wpt8m2Y4fNnukVxuJz3PzSCwEoMqqwa9Qi7e7R
2024-07-25T22:18:38.528Z [INFO]: Purchase successful: 31226025724 tokens bought.
2024-07-25T22:18:38.581Z [INFO]: Buyer SOL balance after purchase: 0.022743187 SOL

I need to get back to this, I will probably make the next release a lot easier to just builder a transaction and allow people to have their own send and sign.

Im going to reproduce it and also see if I can fix the buy/sell results to work with websockets correctly.

Thank you for updating the thread, it will help quite a bit of devs.