A full-stack decentralized application for the ERTH Network ecosystem that provides token management, staking, swapping, and analytics functionalities.
ERTH Network is a blockchain-based platform built on the Secret Network that offers various decentralized finance (DeFi) capabilities including token swapping, staking, liquidity provision, and analytics tracking. This application serves as the main interface for users to interact with the ERTH ecosystem.
- Token Swapping: Exchange ERTH, ANML, and other tokens directly through the interface
- Staking: Stake ERTH tokens to earn rewards
- Liquidity Management: Add or remove liquidity to various token pairs
- Analytics Dashboard: Monitor token prices, market cap, and TVL (Total Value Locked)
- TOTP Authentication: Secure access with time-based one-time passwords
- Secret AI Chat: Interact with AI powered by Secret Network's privacy features
- Agent Chat: Communicate with specialized AI agents
- Public Benefit Fund: Interface for interacting with the network's public benefit fund
- Deflation Fund: Track and interact with the network's deflation mechanism
- ANML Token Claiming: Claim ANML tokens through the dedicated interface
The frontend is built using React.js with the following structure:
- pages/: Main application pages (Analytics, StakeErth, SwapTokens, etc.)
- components/: Reusable UI components
- utils/: Utility functions for common operations
- styles/: CSS and style-related files
- images/: Static image assets
The Node.js backend provides the following services:
- API Endpoints: RESTful services for frontend data requests
- Blockchain Interaction: Communication with Secret Network using secretjs
- Analytics Management: Collection and serving of token and market analytics
- CORS Proxy: Handling cross-origin requests for development
- Node.js v18.20.7 or later
- npm package manager
- Secret Network wallet (for blockchain interactions)
-
Clone the repository:
git clone https://github.com/zenopie/erth-mainnet-app.git cd erth-mainnet-app -
Install frontend dependencies:
npm install -
Install server dependencies:
cd server npm install cd ..
-
Start the frontend development server:
npm startThis runs the app in development mode at http://localhost:3000
-
Start the backend server (in a separate terminal):
cd server node server.js
Build the frontend for production:
npm run build
This creates optimized production files in the build folder.
The application includes an analytics system that tracks token prices, market caps, and other metrics over time.
- Daily data collection at midnight
- Historical data visualization with various time ranges (1W, 1M, All)
- Price change calculation and display
- Support for multiple tokens (ERTH, ANML)
- Reset Analytics:
node server/reset-analytics.js- Resets all analytics data - Migrate Analytics:
node server/migrate-analytics.js- Converts existing analytics data to new format with one entry per day
The application is configured for deployment using GitHub Actions. The workflow automatically:
- Checks out the repository
- Deploys to a remote server via SSH
- Builds the frontend
- Installs dependencies
- Restarts the server using PM2
For manual deployment, follow these steps:
- Build the frontend:
npm run build - Copy the build files to your web server
- Set up the Node.js server with PM2:
pm2 start server/server.js --name "erth-network-server"
erth-network-app/
├── .github/workflows/ # GitHub Actions deployment workflow
├── public/ # Static public assets
├── server/ # Backend Node.js server
│ ├── analyticsManager.js # Analytics data management
│ ├── migrate-analytics.js # Analytics migration script
│ ├── reset-analytics.js # Analytics reset script
│ └── server.js # Main server file
├── src/ # Frontend React application
│ ├── components/ # Reusable UI components
│ ├── pages/ # Application pages
│ ├── utils/ # Utility functions
│ └── App.js # Main React component
└── package.json # Project dependencies and scripts
MIT License
Copyright (c) 2023-2024 ERTH Network
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, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, visit https://erth.network