Skip to content

independenceee/dualtarget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

340 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A Decentralized Automated Trading Bot for ADA Holders

Staking & Asset Growth Solution

Dualtarget Logo

GitHub Stars License: MIT Next.js Go


🎯 Project Overview

Dualtarget is an innovative decentralized automated trading bot specifically designed for Cardano (ADA) holders. This platform bridges the gap between traditional staking and modern automated trading, allowing users to grow their cryptocurrency assets passively while maintaining full control through decentralized mechanisms.

Why Dualtarget?

  • For Stakers: Earn additional returns on your ADA holdings through intelligent algorithmic trading
  • For Traders: Access a decentralized trading infrastructure with minimal fees and maximum transparency
  • For Developers: Build upon a robust, open-source blockchain infrastructure with clean APIs
  • For the Community: Support a fully decentralized, community-driven trading ecosystem

The platform combines cutting-edge blockchain technology with sophisticated trading strategies to provide a seamless experience for managing and growing digital assets.

Watch the Demo Video:

Watch Demo


✨ Key Features

🎰 Staking Integration

  • Earn competitive rewards by staking ADA through integrated pools
  • Real-time stake pool performance monitoring
  • Automatic reward collection and compounding
  • Support for multiple delegation strategies

πŸ€– Automated Trading

  • AI-powered trading algorithms optimized for Cardano ecosystem
  • Support for DEX trading through Minswap SDK
  • Real-time market data from multiple sources (Blockfrost, Koios)
  • Backtesting and strategy simulation tools

πŸ’Ό Asset Management

  • Multi-wallet support with seamless integration
  • Portfolio tracking and performance analytics
  • Transaction history and detailed reporting
  • Secure wallet connections (Chrome extensions)

🌐 Multi-Network Support

  • Mainnet (Production) - Full production trading environment
  • Preprod (Testnet) - Safe testing ground for new features
  • Easy network switching within the application

πŸ”’ Security & Trust

  • Smart contract auditable architecture
  • Non-custodial design - you always control your private keys
  • Transparent transaction validation on-chain
  • Integration with trusted blockchain APIs

🌍 Internationalization

  • Multi-language support (Vietnamese, English, and more)
  • Localized content and documentation
  • Region-specific configurations

πŸ› οΈ Technology Stack

Frontend Architecture

  • Framework: Next.js 14.1.0 - React-based production-ready framework
  • Language: TypeScript - For type-safe development
  • Styling: SCSS/CSS - Modern, modular styling approach
  • State Management: React Context API - Global state handling
  • Wallet Integration: Support for major Cardano wallet extensions

Backend Services

  • Language: Go - High-performance, concurrent processing
  • API Layer: RESTful architecture with clean endpoints
  • Database: PostgreSQL - Reliable data persistence
  • Docker: Containerized deployment and scaling

Blockchain Integration

  • Blockfrost API: Primary blockchain data provider
  • Koios API: Backup blockchain data source
  • Minswap SDK: DEX protocol integration
  • Cardano: Native blockchain network

Additional Tools

  • Git: Version control and collaboration
  • Docker Compose: Multi-container orchestration
  • npm/Node.js: Package management

πŸ“ Project Structure

Directory Overview

dualtarget/
β”œβ”€β”€ frontend/                 # Next.js React Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/             # Next.js App Router (pages and routes)
β”‚   β”‚   β”œβ”€β”€ assets/          # Images, icons, fonts
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable React components
β”‚   β”‚   β”œβ”€β”€ configs/         # Configuration files
β”‚   β”‚   β”œβ”€β”€ constants/       # Static constant values
β”‚   β”‚   β”œβ”€β”€ contexts/        # Global state management
β”‚   β”‚   β”œβ”€β”€ data/            # Static data (FAQs, guides)
β”‚   β”‚   β”œβ”€β”€ helpers/         # Utility helper functions
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ layouts/         # Layout components
β”‚   β”‚   β”œβ”€β”€ libs/            # Third-party integrations
β”‚   β”‚   β”œβ”€β”€ services/        # API services
β”‚   β”‚   β”œβ”€β”€ styles/          # Global styles
β”‚   β”‚   β”œβ”€β”€ translations/    # i18n translation files
β”‚   β”‚   └── types/           # TypeScript type definitions
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   β”œβ”€β”€ Dockerfile           # Container configuration
β”‚   β”œβ”€β”€ docker-compose.yml   # Docker Compose setup
β”‚   β”œβ”€β”€ next.config.mjs      # Next.js configuration
β”‚   β”œβ”€β”€ tsconfig.json        # TypeScript configuration
β”‚   └── package.json         # Dependencies
β”‚
β”œβ”€β”€ backend/                 # Go REST API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.go          # Entry point
β”‚   β”‚   β”œβ”€β”€ api/             # External API integrations
β”‚   β”‚   β”œβ”€β”€ configs/         # Configuration management
β”‚   β”‚   β”œβ”€β”€ constants/       # Constants and enums
β”‚   β”‚   β”œβ”€β”€ controllers/     # API request handlers
β”‚   β”‚   β”œβ”€β”€ data/            # Data structures
β”‚   β”‚   β”œβ”€β”€ dto/             # Data transfer objects
β”‚   β”‚   β”œβ”€β”€ helpers/         # Utility functions
β”‚   β”‚   β”œβ”€β”€ models/          # Database models
β”‚   β”‚   β”œβ”€β”€ repository/      # Database access layer
β”‚   β”‚   β”œβ”€β”€ routers/         # Route definitions
β”‚   β”‚   β”œβ”€β”€ services/        # Business logic
β”‚   β”‚   └── utils/           # General utilities
β”‚   β”œβ”€β”€ Dockerfile           # Container configuration
β”‚   β”œβ”€β”€ docker-compose.yml   # Docker Compose setup
β”‚   β”œβ”€β”€ go.mod               # Go module definition
β”‚   └── go.sum               # Dependency checksums
β”‚
└── database/                # Database setup and migrations
    └── docker-compose.yml   # Database container configuration

Frontend Directory Details

Directory Purpose Contains
app Route management using Next.js App Router Page components, layout components, route definitions
assets Static project resources PNG/SVG images, icon fonts, custom fonts, brand assets
components Reusable UI components Button, Input, Modal, Card, Chart, Table, etc.
configs Application configuration Route definitions, wallet configurations, API endpoints
constants Static application data Environment names, wallet lists, network info, headers
contexts Global state management User context, wallet context, theme context
data Static content FAQ items, guide content, founder information
helpers Utility functions Network validation, date conversion, data formatting
hooks Custom React hooks useWallet, useCopy, useLocalStorage, custom logic hooks
layouts Layout components Header, Footer, Sidebar, navigation structures
libs Third-party integrations SDK initialization, external library wrappers
services API integration layer Blockfrost service, Koios service, transaction service
styles Global styling Global CSS/SCSS, variables, mixins, theme definitions
translations i18n files Translation JSON for multiple languages
types TypeScript types Custom type definitions, interfaces, enums

Key Configuration Files

  • wallets.ts - Configuration for supported Cardano wallets (Eternl, Nami, etc.)
  • routes.ts - Application route definitions and navigation structure
  • networks.ts - Network configuration (Mainnet, Preprod, custom RPC endpoints)

Backend Directory Details

The Go backend provides RESTful APIs for:

  • Account Management - User profile, authentication, account settings
  • Transaction Processing - Transaction creation, validation, and monitoring
  • Mail Services - Notifications and email communications
  • Blockchain Integration - Communication with Cardano network

πŸš€ Quick Start

Get up and running in just 5 minutes!

Prerequisites Checklist

Before starting, ensure you have:

# Check Git installation
git --version

# Check Node.js installation (v16 or higher)
node --version
npm --version

# Optional: Check Docker installation
docker --version

1. Clone the Repository

# Clone the repository from GitHub
git clone https://github.com/independenceee/dualtarget.git

# Navigate to the frontend directory
cd dualtarget/frontend

# (Optional) Check the available branches
git branch -a

2. Set Up Environment Variables

Create or update next.config.mjs with your blockchain API keys:

  1. Get Blockfrost API Key:

    • Visit blockfrost.io
    • Sign up for a free account
    • Create a new project
    • Copy your API key for Mainnet and/or Preprod
  2. Get Koios API Key (Optional):

    • Visit koios.rest
    • Review documentation
    • Use the public API endpoint or get your own
  3. Configure next.config.mjs:

const nextConfig = {
  env: {
    // ===== MAINNET CONFIGURATION =====
    BLOCKFROST_NETWORK_NAME_MAINNET: "Mainnet",
    BLOCKFROST_RPC_URL_MAINNET: "https://cardano-mainnet.blockfrost.io/api/v0",
    BLOCKFROST_PROJECT_API_KEY_MAINNET: "YOUR_BLOCKFROST_MAINNET_KEY",
    KOIOS_RPC_URL_MAINNET: "https://api.koios.rest/api/v1",
    NEXT_APP_BASE_URL_MAINNET: "https://api.dualtarget.vn/api/v1",
    DUALTARGET_CONTRACT_ADDRESS_MAINNET: "your_contract_address",
    DUALTARGET_PAYMENT_ADDRESS_MAINNET: "your_payment_address",
    DUALTARGET_STAKE_ADDRESS_MAINNET: "your_stake_address",
    POOL_ID_MAINNET: "pool1rqgf6qd0p3wyf9dxf2w7qcddvgg4vu56l35ez2xqemhqun2gn7y",

    // ===== PREPROD (TESTNET) CONFIGURATION =====
    BLOCKFROST_NETWORK_NAME_PREPROD: "Preprod",
    BLOCKFROST_RPC_URL_PREPROD: "https://cardano-preprod.blockfrost.io/api/v0",
    BLOCKFROST_PROJECT_API_KEY_PREPROD: "YOUR_BLOCKFROST_PREPROD_KEY",
    KOIOS_RPC_URL_PREPROD: "https://preprod.koios.rest/api/v1",
    NEXT_APP_BASE_URL_PREPROD: "https://preprod.dualtarget.vn/api/v1",
    DUALTARGET_CONTRACT_ADDRESS_PREPROD: "your_contract_address",
    DUALTARGET_PAYMENT_ADDRESS_PREPROD: "your_payment_address",
    DUALTARGET_STAKE_ADDRESS_PREPROD:
      "stake_test1uq7cj74n8ryrmg20rasqnqcygv4kwrmn2yjemkv3ux2k7lgqu950l",
    POOL_ID_PREPROD: "pool1ke9h4mggr8ttf45ale5dv4ntkvuw2wkvm6la4mv02688xuy99qp",
  },
};

export default nextConfig;

3. Choose Your Installation Method

🐳 Option A: Docker (Recommended - One Command!)

Advantages: No local dependencies, consistent environment, easy cleanup

# Ensure Docker is running, then execute:
docker compose up --build

# The application will start automatically and be available at:
# http://localhost:3000

# To stop: Press Ctrl+C or run:
docker compose down

πŸ“¦ Option B: Node.js (More Control)

Advantages: Faster iteration, easier debugging, no Docker overhead

# Install project dependencies
npm install
# This downloads all required packages (may take 2-3 minutes on first run)

# Start the development server
npm run dev
# Server will start at http://localhost:3000
# Press Ctrl+C to stop the server

# Watch for file changes and auto-reload enabled

πŸ“¦ Installation

Step 1: Verify Prerequisites

Make sure you have all required software installed:

# Verify Git
git --version
# Should output: git version X.X.X...

# Verify Node.js (16.0.0 or higher)
node --version
npm --version
# Should output versions like v18.x.x and 9.x.x

# Verify Docker (if using Docker method)
docker --version
docker compose --version

Step 2: Clone and Navigate

git clone https://github.com/independenceee/dualtarget.git
cd dualtarget/frontend

Step 3: Environment Configuration

Configure your .env.local or next.config.mjs with API endpoints:

  1. Blockfrost Setup (Primary):

    • Create account at blockfrost.io
    • Generate API keys for desired networks
    • Add to configuration
  2. Koios Setup (Optional Backup):

    • Visit koios.rest
    • Can use public endpoints or register for custom ones

Step 4: Run the Application

Using Docker:

docker compose up --build

Using Node.js:

npm install
npm run dev

Both will launch at http://localhost:3000

Step 5: Build for Production

When ready to deploy:

# Create optimized production build
npm run build

# Test production build locally
npm run start
# Application runs at http://localhost:3000 in production mode

# Verify bundle size
npm run analyze  # If available

πŸ’» Development

Available Scripts

# Start development server with hot reload
npm run dev

# Build optimized production bundle
npm run build

# Start production server
npm run start

# Run linting checks (ESLint)
npm run lint

# Run tests (if configured)
npm run test

# Format code (Prettier)
npm run format

# Type checking
npm run type-check

Development Guidelines

  • Component Structure: Keep components small and focused (max 300 lines)
  • Naming Convention: Use PascalCase for components, camelCase for functions
  • Styling: Use SCSS modules for component-specific styles
  • Type Safety: Always define TypeScript types/interfaces
  • Comments: Document complex logic with clear comments
  • Testing: Write unit tests for utilities and complex components

Useful Development Resources


πŸ”§ Configuration

Environment Variables

Network Configuration

BLOCKFROST_NETWORK_NAME_*: Network display name
BLOCKFROST_RPC_URL_*: Blockchain API endpoint
BLOCKFROST_PROJECT_API_KEY_*: Your Blockfrost API key

Contract Addresses

DUALTARGET_CONTRACT_ADDRESS_*: Main contract address
DUALTARGET_PAYMENT_ADDRESS_*: Payment address
DUALTARGET_STAKE_ADDRESS_*: Staking address

API Endpoints

NEXT_APP_BASE_URL_*: Backend API base URL
KOIOS_RPC_URL_*: Koios blockchain API

Supported Networks

  1. Mainnet (Production)

    • Real ADA transactions
    • Live stake pools
    • Production contracts
  2. Preprod (Testnet)

    • Free test ADA (from faucet)
    • Development/testing only
    • Safe for experimentation

Wallet Configuration

Edit configs/wallets.ts to add/modify supported wallet extensions:

export const WALLET_EXTENSIONS = {
  eternl: { name: "Eternl", extension: "..." },
  nami: { name: "Nami", extension: "..." },
  // Add more wallets as needed
};

πŸ“š API Documentation

Backend API Endpoints

Account Endpoints

  • POST /api/v1/accounts/register - Create new account
  • POST /api/v1/accounts/login - User authentication
  • GET /api/v1/accounts/{id} - Get account details
  • PUT /api/v1/accounts/{id} - Update account info

Transaction Endpoints

  • POST /api/v1/transactions/create - Create transaction
  • GET /api/v1/transactions/{id} - Get transaction details
  • GET /api/v1/transactions - List user transactions
  • POST /api/v1/transactions/{id}/sign - Sign transaction

Staking Endpoints

  • GET /api/v1/staking/pools - List available pools
  • POST /api/v1/staking/delegate - Delegate to pool
  • GET /api/v1/staking/rewards - Get staking rewards
  • GET /api/v1/staking/status - Check delegation status

Mail Endpoints

  • POST /api/v1/mail/send - Send email notification
  • POST /api/v1/mail/subscribe - Subscribe to notifications

Response Format

All API responses follow this standard format:

{
  "status": "success|error",
  "data": {
    /* response payload */
  },
  "message": "Human readable message",
  "timestamp": "2024-01-01T00:00:00Z"
}

πŸ› Troubleshooting

Common Issues & Solutions

Port 3000 Already in Use

# On Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F

# On macOS/Linux
lsof -ti:3000 | xargs kill -9

Node Modules Issues

# Clear npm cache
npm cache clean --force

# Remove node_modules and package-lock
rm -rf node_modules package-lock.json

# Reinstall
npm install

Docker Issues

# Remove containers and rebuild
docker compose down -v
docker compose up --build

# Check logs
docker compose logs -f

API Connection Errors

  • Verify API keys in next.config.mjs
  • Check network selection (Mainnet vs Preprod)
  • Ensure backend API is running
  • Check firewall/VPN settings

Wallet Connection Issues

  • Clear browser cache and cookies
  • Disable browser extensions temporarily
  • Try different Cardano wallet extension
  • Check wallet is unlocked and connected to correct network

Debug Mode

Enable detailed logging:

// In your component
const DEBUG = process.env.NODE_ENV === "development";

if (DEBUG) {
  console.log("Debug information...");
}

Getting Help

  1. Check GitHub Issues
  2. Review documentation
  3. Contact support (see below)
  4. Submit detailed bug report with:
    • Error message
    • Steps to reproduce
    • Browser/OS information
    • Network (Mainnet/Preprod)

πŸ“„ License

This project is released under the MIT License.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...

See LICENSE file for full text.

πŸ’¬ Contact & Support

Get in Touch

Community

  • Follow us on GitHub for updates
  • Check GitHub Discussions for community topics
  • Report bugs with detailed information
  • Share feature requests and suggestions

Contributing

We welcome contributions! Please:

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

Support Channels

  • πŸ“– Documentation: Check the README and code comments
  • πŸ› Bug Reports: Use GitHub Issues
  • πŸ’¬ General Questions: Use GitHub Discussions
  • πŸ“§ Direct Contact: Email the maintainer

Made with ❀️ for the Cardano Community

Cardano β€’ Minswap β€’ Blockfrost β€’ Koios

About

Dualtarget for ADA-Holders (Staking and increasing assets) with a decentralized automated trading bot.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors