PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, July 28, 2022

[FIXED] How to find out if a transaction is finalized on Solana

 July 28, 2022     anchor-solana, blockchain, javascript, node.js, solana     No comments   

Issue

How do you get the current status of a transaction on Solana with the Solana Javascript API (@solana/web3.js)?

https://solscan.io/tx/4fwgX16WDwYj5hZ2t5xEHz6UUnuaTovJpMeoWWEBvuA7z1baf1qX1BW2EGZVR9ChSyJZ8akeLX6EDTadFcEcSTdy

This is what I've tried, but it only seems to work for recent transactions.

const { Connection, clusterApiUrl } = require("@solana/web3.js");

(async () => {
    const connection = new Connection(clusterApiUrl('mainnet-beta'));
    const status = await connection.getSignatureStatus("4fwgX16WDwYj5hZ2t5xEHz6UUnuaTovJpMeoWWEBvuA7z1baf1qX1BW2EGZVR9ChSyJZ8akeLX6EDTadFcEcSTdy");
    console.log(status);
})();

Solution

Try adding searchTransactionHistory: true to the SignatureStatusConfig

const getConfirmation = async (connection: Connection, tx: string) => {
  const result = await connection.getSignatureStatus(tx, {
    searchTransactionHistory: true,
  });
  return result.value?.confirmationStatus;
};

https://docs.solana.com/developing/clients/jsonrpc-api#getsignaturestatuses



Answered By - dr497
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing