🔗sol

Description

The txStatus function is used to check the status of a transaction on the Solana blockchain. It takes a transaction hash and an environment as inputs and returns the status of the transaction. The function first validates the transaction hash and environment inputs, then uses the Solana RPC URL corresponding to the given environment to connect to the Solana blockchain. Finally, it retrieves the transaction status and returns it.

Parameters

Parameter NameData TypeDescription

txHash

string

The hash of the transaction to check the status for

env

string

The environment to connect to (e.g. 'devnet', 'mainnet')

Response

Field NameData TypeDescription

code

number

A code indicating the result of the function (1 for success, 0 for failure)

result

string

The status of the transaction ('confirmed' if successful, 'failed' if not)

error

string

An error message, returned if code is 0

Example Request and Response

Prerequisites

Before making requests with Nest SDK, you must have it installed.

You can install Nest SDK using either npm or yarn. Use the following commands to install Nest SDK:

npm install @nest25/wallet-lib
OR
yarn add @nest25/wallet-lib

Request

Here is an example of how to make a txStatus request using the Nest SDK:

// import Nest SDK
import { Wallet } from 'nest25/wallet-lib';

// Create a new instance of the Wallet class
const wallet = new Wallet();

const main = async () => {
  // Get the status of a transaction
  const response = await wallet.txStatus(
    'sol',
    '4iDWwQDUoasbZZS9ARdSydrLdFqMcNC1RDfqarAQgbRXpFXty624PQ3Z3AMnoiioKLJyCwtfpG5owHLAcWFr9ywa',
  );
  // Print the response
  console.log(response);
};

main();

Response

   { code: 1, result: 'confirmed' }

Use Cases

  • Wallet Applications: Wallet applications can use this function to retrieve the status of transactions made by the user and update the transaction history accordingly.

  • Explorers: Blockchain explorers can use this function to provide information on the status of transactions on the Solana blockchain.

Last updated