# XChainJS Check Transaction Example

Published: (December 19, 2025 at 11:36 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Live Demo & Source Code

  • Live demo (CodeSandbox):
  • Source code (GitHub):

What This Example Does

The project shows how to check the status of a transaction with XChainJS. It covers:

  • Fetching transaction information by hash
  • Checking confirmations and finality
  • Handling pending vs. confirmed transactions
  • Using a chain‑agnostic API for transaction lookup

Useful for developers building:

  • Crypto wallets
  • Transaction history pages
  • Blockchain explorers
  • Monitoring and alerting services
  • Cross‑chain backends

Tech Stack

  • TypeScript
  • Node.js
  • XChainJS
  • @xchainjs/xchain-util
  • Chain clients from the XChainJS ecosystem

Project Location

Inside the XChainJS monorepo:

examples/
 └─ check-tx/

The example focuses on transaction status logic, without UI code.

How Transaction Checking Works

Transaction Hash

XChainJS Chain Client

Fetch Transaction Data

Check Confirmations & Status

Return Result

Core Concepts

Transaction Hash

A transaction hash uniquely identifies an on‑chain transaction. This example shows how to use a hash to query the blockchain and retrieve transaction details.

Transaction Status

Depending on the chain, a transaction can be:

  • pending
  • confirmed
  • failed

XChainJS abstracts these differences and provides a consistent interface for checking transaction status across chains.

Installation

Clone the repository

git clone https://github.com/xchainjs/xchainjs-lib.git
cd xchainjs-lib/examples/check-tx

Install dependencies

npm install

Run the example

npm start

Running in the Browser

You can also run this example instantly using CodeSandbox.

Code Example (Simplified)

import { getClient } from '@xchainjs/xchain-thorchain'

const txHash = 'YOUR_TRANSACTION_HASH'

async function checkTx() {
  const client = getClient()
  const tx = await client.getTransactionData(txHash)

  if (!tx) {
    throw new Error('Transaction not found')
  }

  console.log(tx)
}

checkTx()

This pattern can be reused for different chains by switching clients.

Why Use XChainJS for Transaction Monitoring

  • Unified API for multiple blockchains
  • TypeScript‑first for safer code
  • Reusable client abstractions
  • Suitable for wallets and production backends

When This Example Is Useful

Use this example if you are:

  • Learning how transaction tracking works
  • Building a wallet transaction history
  • Implementing confirmations logic
  • Monitoring cross‑chain transactions
  • Working with XChainJS clients
  • XChainJS GitHub:
  • XChainJS utilities:
  • Live check transaction example:

Summary

This example provides a simple, runnable reference for checking blockchain transactions using XChainJS. It serves as a solid foundation for building transaction‑aware applications such as wallets, explorers, and monitoring services.

Back to Blog

Related posts

Read more »

# `@xchainjs/xchain-ethereum`

@xchainjs/xchain-ethereum is the official Ethereum client for the XChainJS ecosystem — a modular, TypeScript‑first SDK for building cross‑chain wallets, crypto...

# `@xchainjs/xchain-litecoin`

Litecoin LTC client and utilities for XChainJS A lightweight TypeScript SDK for building cross‑chain wallets, crypto payment flows, and DeFi tooling with a com...

Vue + XChainJS Example

!Cover image for Vue + XChainJS Examplehttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads...