Skip to content

antontuzov/DapFor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

NEAR Intents DEX

A full-stack decentralized exchange (DEX) application inspired by near-intents.org that enables cross-chain trading using an "intents" model.

Features

  • Connect NEAR wallet
  • Perform token swaps by stating intent
  • View account balances and trade history
  • Switch between Swap and OTC trading interfaces
  • Deposit and withdraw funds

Tech Stack

  • Frontend: Vite.js + React (TypeScript) with Tailwind CSS
  • Backend: Go with Gin framework
  • Blockchain: NEAR Protocol integration

Project Structure

project-root/
├── frontend/                 # React frontend
│   ├── public/
│   ├── src/
│   │   ├── assets/
│   │   ├── components/
│   │   │   ├── Layout/
│   │   │   ├── Swap/
│   │   │   ├── OTC/
│   │   │   ├── Account/
│   │   │   ├── History/
│   │   │   └── common/
│   │   ├── pages/
│   │   ├── hooks/
│   │   ├── services/
│   │   ├── store/
│   │   └── types/
│   ├── package.json
│   └── ...
└── backend/                  # Go backend
    ├── cmd/
    │   └── api/
    │       └── main.go
    ├── internal/
    │   ├── handlers/
    │   ├── middleware/
    │   ├── models/
    │   ├── services/
    │   └── utils/
    ├── go.mod
    └── go.sum

Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • Go (v1.20 or higher)

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create a .env file in the frontend directory:
REACT_APP_API_URL=http://localhost:8080/api
  1. Start the development server:
npm run dev

The frontend will be available at http://localhost:5173

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Create a .env file in the backend directory:
PORT=8080
JWT_SECRET=your-super-secret-jwt-key-change-in-production
GIN_MODE=debug
  1. Run the server:
go run cmd/api/main.go

The backend API will be available at http://localhost:8080

Running Both Services

For development, you can run both services simultaneously:

  1. Terminal 1 (Backend):
cd backend
go run cmd/api/main.go
  1. Terminal 2 (Frontend):
cd frontend
npm run dev

API Endpoints

Authentication

  • POST /api/auth/nonce - Get nonce for authentication
  • POST /api/auth/verify - Verify signature and get JWT

User

  • GET /api/user/balance - Get user balances (requires auth)
  • GET /api/deposit/address - Get deposit address

Intents

  • POST /api/intents/swap - Create swap intent (requires auth)
  • POST /api/intents/otc/create - Create OTC offer (requires auth)
  • GET /api/intents/otc/list - List active OTC offers
  • POST /api/intents/otc/take - Take OTC offer (requires auth)
  • GET /api/intents/history - Get trade history (requires auth)

Withdraw

  • POST /api/withdraw - Request withdrawal (requires auth)

Architecture

The application follows a microservices architecture with a separate frontend and backend. The backend uses an in-memory store for demonstration purposes, but the architecture is designed to easily integrate with NEAR blockchain services.

Wallet Integration

The application integrates with NEAR wallet for user authentication and transaction signing. The wallet connection is handled through the NEAR JavaScript SDK.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT

About

A full-stack decentralized exchange (DEX) application inspired by near-intents.org that enables cross-chain trading using an "intents" model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors