How do you get the current status of a transaction on Solana with the Solana Javascript API (@solana/web3.js)?
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);
})();
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