Giter VIP home page Giter VIP logo

Comments (5)

zerotop avatar zerotop commented on September 3, 2024 1

An even better addition:

// Execute the transaction
var tryAgain=true;
var objSignatureStatusResult;
var maxTriesCounter=0; 
var maxTries=5; 

while (tryAgain) {
	maxTriesCounter++;
	const rawTransaction = transaction.serialize()
	const txid = await connection.sendRawTransaction(rawTransaction, {
	  skipPreflight: true,
	  maxRetries: 2
	});

	console.log(`https://solscan.io/tx/${txid}`);
	await new Promise(r => setTimeout(r, 1500));

	const result = await connection.getSignatureStatus(txid, {
		searchTransactionHistory: true,
		});
	objSignatureStatusResult = JSON.parse(JSON.stringify(result));
	if ( objSignatureStatusResult.value !== null) tryAgain=false;
	if (maxTriesCounter>maxTries) tryAgain=false;
}

from jupiter-core-example.

Marijus avatar Marijus commented on September 3, 2024 1

I'm facing the exact same issue. If I try to swap a less busy token - it works almost every time, however, with busier tokens it rarely succeeds. Did you ever find a solution to the problem?

from jupiter-core-example.

zerotop avatar zerotop commented on September 3, 2024

For me it helped to wait 5 seconds and use another way to validate the transaction:

await new Promise(r => setTimeout(r, 5000));

 const result = await connection.getSignatureStatus(txid, {
    searchTransactionHistory: true,
  });
  console.log(result);

from jupiter-core-example.

Jandzi avatar Jandzi commented on September 3, 2024

An even better addition:

// Execute the transaction
var tryAgain=true;
var objSignatureStatusResult;
var maxTriesCounter=0; 
var maxTries=5; 

while (tryAgain) {
	maxTriesCounter++;
	const rawTransaction = transaction.serialize()
	const txid = await connection.sendRawTransaction(rawTransaction, {
	  skipPreflight: true,
	  maxRetries: 2
	});

	console.log(`https://solscan.io/tx/${txid}`);
	await new Promise(r => setTimeout(r, 1500));

	const result = await connection.getSignatureStatus(txid, {
		searchTransactionHistory: true,
		});
	objSignatureStatusResult = JSON.parse(JSON.stringify(result));
	if ( objSignatureStatusResult.value !== null) tryAgain=false;
	if (maxTriesCounter>maxTries) tryAgain=false;
}

You are a life saver, thank you very much! Everything works now!

from jupiter-core-example.

Jandzi avatar Jandzi commented on September 3, 2024

I'm facing the exact same issue. If I try to swap a less busy token - it works almost every time, however, with busier tokens it rarely succeeds. Did you ever find a solution to the problem?

Yes, as zerotop pointed out, you have to add the while loop, that basically retries to executing the transaction.

from jupiter-core-example.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.