A full-stack decentralized exchange (DEX) application inspired by near-intents.org that enables cross-chain trading using an "intents" model.
- 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
- Frontend: Vite.js + React (TypeScript) with Tailwind CSS
- Backend: Go with Gin framework
- Blockchain: NEAR Protocol integration
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
- Node.js (v16 or higher)
- Go (v1.20 or higher)
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Create a
.envfile in the frontend directory:
REACT_APP_API_URL=http://localhost:8080/api- Start the development server:
npm run devThe frontend will be available at http://localhost:5173
- Navigate to the backend directory:
cd backend- Create a
.envfile in the backend directory:
PORT=8080
JWT_SECRET=your-super-secret-jwt-key-change-in-production
GIN_MODE=debug- Run the server:
go run cmd/api/main.goThe backend API will be available at http://localhost:8080
For development, you can run both services simultaneously:
- Terminal 1 (Backend):
cd backend
go run cmd/api/main.go- Terminal 2 (Frontend):
cd frontend
npm run devPOST /api/auth/nonce- Get nonce for authenticationPOST /api/auth/verify- Verify signature and get JWT
GET /api/user/balance- Get user balances (requires auth)GET /api/deposit/address- Get deposit address
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 offersPOST /api/intents/otc/take- Take OTC offer (requires auth)GET /api/intents/history- Get trade history (requires auth)
POST /api/withdraw- Request withdrawal (requires auth)
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.
The application integrates with NEAR wallet for user authentication and transaction signing. The wallet connection is handled through the NEAR JavaScript SDK.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT