Transaction Example

This example demonstrates how to use the @crypto.com/developer-platform-client Transaction module to interact with blockchain transactions.

Installation

1. Clone the repository

git clone https://github.com/crypto-com/developer-platform-sdk-examples.git

2. Install dependencies

cd developer-platform-sdk-examples/sdk-examples/categories/transaction
npm install

Environment Variables

This example uses a client-side SDK and may require an API key. You can initialize the SDK inside your app (src/app/Transaction/index.tsx) code like so:

import { Client } from "@crypto.com/developer-platform-client";

Client.init({
  apiKey: "your-crypto.com-developer-platform-api-key",
});

Note: Never expose real or production API keys in a public or client-side app.

Features

This example showcases the following Transaction module functions:

  • getTransactionByHash: Fetch a transaction by its hash

  • getTransactionStatus: Check transaction status by hash

Other functions provided by the @crypto.com/developer-platform-client Transaction module can also be integrated into the app:

  • getTransactionsByAddress: Fetch transactions for a specific wallet address

  • getTransactionCount: Get transaction count for a wallet

  • getGasPrice: Fetch current gas price

  • getFeeData: Get current fee data

  • estimateGas: Estimate gas for a transaction

Usage

To run the app in development mode:

npm run dev

Open your browser and navigate to the provided local URL (typically http://localhost:5173).

The application provides a user interface to test Transaction module functions. You can:

  • Enter transaction hashes to fetch detailed transaction information

  • Check the current status of any transaction

  • View formatted JSON responses with transaction data

Build

To generate a production-ready build:

npm run build

To preview the build:

npm run preview

Development

  • npm run dev - Start development server

  • npm run build - Build for production

  • npm run lint - Run ESLint

  • npm run preview - Preview production build

API Key Requirements

Some functions may require valid API credentials. Make sure to provide valid credentials when testing blockchain transaction features.

Demo Video

Last updated

Was this helpful?