Thanks to visit codestin.com
Credit goes to github.com

Skip to content

karar189/blockchain-indexer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ CosmoDEX - Blockchain Indexing Platform

IMAGE 2025-03-30 17:34:10

A powerful platform for indexing Solana blockchain data using Helius API and storing it in your own PostgreSQL database.

πŸ“Ί Product Walkthrough

CosmoDEX Walkthrough Video

Click the image above to watch our walkthrough video

πŸ”Ž Overview

This platform allows developers to easily set up and manage Solana blockchain indexers using the Helius API and their own PostgreSQL database. The system provides a comprehensive set of features for configuring, monitoring, and managing blockchain data indexing in a user-friendly way through Helius API.

IMAGE 2025-03-30 17:34:27

πŸ–‹οΈ Hosted Link: Live link

✨ Features

  • πŸ” User Authentication: Secure registration and login system
  • πŸ—„οΈ Database Management: Connect and manage your PostgreSQL databases
  • βš™οΈ Indexer Configuration: Create custom indexers with specific filters and transformations
  • πŸ”— Helius Integration: Seamless connection to Solana blockchain via Helius API
  • ⚑ Real-time Indexing: Process blockchain data as it happens
  • πŸ”„ Customizable Transformations: Define how data should be structured in your database
  • πŸ“Š Dashboard & Monitoring: Track performance and troubleshoot issues

πŸ“‹ Installation

Prerequisites

  • πŸ“¦ Node.js (v14 or higher)
  • 🐘 PostgreSQL (v12 or higher)
  • πŸ”‘ Helius API key (sign up at https://helius.xyz)

Backend Setup

  1. Clone the repository:
git clone https://github.com/yourusername/blockchain-indexing-platform.git
cd blockchain-indexing-platform/backend
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env

Edit the .env file with your database and Helius API credentials.

  1. Run migrations:
npm run migration:run
  1. Start the server:
npm run start:dev

Frontend Setup

  1. Navigate to the frontend directory:
cd ../frontend
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env.local

Edit the .env.local file with your backend API URL.

  1. Start the development server:
npm run dev

🚦 Quick Start Guide

  1. πŸ‘€ Register an account at {your-domain}/auth/register
  2. πŸ”Œ Add a database connection with your PostgreSQL credentials
  3. πŸ› οΈ Create an indexer with your desired filters and transformations
  4. ▢️ Activate the indexer to start receiving blockchain data
  5. πŸ“ˆ Monitor the dashboard to see your indexed data in action

πŸ“š API Documentation

Authentication

Endpoint Method Description
/auth/register POST Create a new user account
/auth/login POST Authenticate and receive a JWT token
/auth/profile GET Get the current user's profile

Database Connections

Endpoint Method Description
/database GET List all database connections
/database POST Create a new database connection
/database/test POST Test database connection credentials
/database/{id} GET Get a specific database connection
/database/{id} PATCH Update a database connection
/database/{id} DELETE Delete a database connection

Indexers

Endpoint Method Description
/indexer GET List all indexers
/indexer POST Create a new indexer
/indexer/{id} GET Get a specific indexer
/indexer/{id} PATCH Update an indexer
/indexer/{id} DELETE Delete an indexer
/indexer/{id}/activate POST Activate an indexer
/indexer/{id}/deactivate POST Deactivate an indexer
/indexer/stats GET Get overall indexing statistics
/indexer/{id}/metrics GET Get metrics for a specific indexer
/indexer/{id}/logs GET Get logs for a specific indexer

Helius Integration

Endpoint Method Description
/helius/webhooks GET List all Helius webhooks
/helius/webhook POST Create a new Helius webhook
/helius/webhook/{id} GET Get a specific webhook
/helius/webhook/{id} PUT Update a webhook
/helius/webhook/{id} DELETE Delete a webhook
/helius/nft/metadata POST Get enhanced NFT metadata

Webhook Reception

Endpoint Method Description
/webhook POST Receive incoming webhook data from Helius

πŸ’» Example Usage

Creating a Database Connection

const response = await fetch('https://your-api.com/database', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    name: 'Production Database',
    host: 'db.example.com',
    port: 5432,
    username: 'dbuser',
    password: 'dbpassword',
    database: 'blockchain_data'
  })
});

const data = await response.json();
console.log('Database connection created:', data);

Creating an Indexer for NFT Transactions

const response = await fetch('https://your-api.com/indexer', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    name: 'NFT Transactions Indexer',
    description: 'Indexes all NFT transactions on Solana',
    databaseConnectionId: 'db-connection-uuid-1',
    schemaName: 'nft_data',
    filters: {
      programIds: [
        'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'
      ],
      transactionTypes: ['NFT_SALE']
    },
    transformations: {
      includeMetadata: true,
      customFields: [
        {
          name: 'seller_address',
          path: 'events[0].source',
          type: 'string'
        },
        {
          name: 'buyer_address',
          path: 'events[0].destination',
          type: 'string'
        },
        {
          name: 'sale_amount',
          path: 'events[0].amount',
          type: 'numeric'
        }
      ]
    }
  })
});

const data = await response.json();
console.log('Indexer created:', data);

πŸ—οΈ Project Structure

blockchain-indexer/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication module
β”‚   β”‚   β”œβ”€β”€ database/          # Database connection management
β”‚   β”‚   β”œβ”€β”€ helius/            # Helius API integration
β”‚   β”‚   β”œβ”€β”€ indexer/           # Core indexing logic
β”‚   β”‚   β”œβ”€β”€ webhook/           # Webhook processing
β”‚   β”‚   └── main.ts            # Application entry point
β”‚   └── ...
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ pages/             # Next.js page components
β”‚   β”‚   β”œβ”€β”€ services/          # API service integrations
β”‚   β”‚   └── ...
β”‚   └── ...
└── ...

πŸ‘¨β€πŸ’» Development

Setting Up the Development Environment

  1. Fork and clone the repository
  2. Set up the backend and frontend as described in the installation section
  3. Create a new branch for your feature or bug fix
  4. Make your changes
  5. Run tests to ensure everything works correctly
  6. Submit a pull request

Running Tests

# Backend tests
cd backend
npm run test

# Frontend tests
cd frontend
npm run test

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Helius - For their powerful Solana blockchain API
  • NestJS - For the backend framework
  • Next.js - For the frontend framework
  • All contributors who have helped shape this project

πŸ“¬ Contact

For any questions or support, please open an issue or contact the maintainers at Sweta Karar.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages