A secure and production-ready REST API server for interacting with FairCoin's RPC interface. This server provides a web-friendly API layer over FairCoin's JSON-RPC protocol, making it easy to integrate FairCoin functionality into web applications and services.
FairCoin Website: https://fairco.in/
- 🔒 Security First: Helmet for security headers, rate limiting, and environment-based configuration
- 🚀 Production Ready: CORS support, request logging, and error handling
- 📊 FairCoin Integration: Direct access to FairCoin RPC methods
- 🛡️ Rate Limiting: Built-in protection against abuse
- 📝 Comprehensive Logging: Morgan-based HTTP request logging
- 🏥 Health Checks: Built-in health endpoint for monitoring
- Node.js (v16 or higher)
- npm or yarn
- Access to a FairCoin RPC server
- Git
-
Clone the repository:
git clone https://github.com/FairCoinOfficial/FairRPCAPIServer.git cd FairRPCAPIServer -
Install dependencies:
npm install
-
Configure environment variables: Create a
.envfile in the root directory:PORT=3000 RPC_USER=your_rpc_username RPC_PASS=your_secure_rpc_password RPC_PORT=40405 RPC_HOST=your_faircoin_rpc_host
Security Note: Never commit your
.envfile to version control. It's already included in.gitignore.
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port | 3000 | No |
RPC_USER |
FairCoin RPC username | - | Yes |
RPC_PASS |
FairCoin RPC password | - | Yes |
RPC_PORT |
FairCoin RPC port | 40405 | Yes |
RPC_HOST |
FairCoin RPC host | - | Yes |
npm run devnpm startThe server will start on the configured port (default: 3000).
- GET
/health - Returns server status and timestamp
- GET
/api/networkinfo - Returns FairCoin network information
- GET
/api/blockchaininfo - Returns blockchain statistics and status
- GET
/api/peerinfo - Returns information about connected peers
{
"version": 210000,
"subversion": "/FairCoin:2.1.0/",
"protocolversion": 70016,
"connections": 8,
"relayfee": 0.00001
}-
Connect your repository:
- Go to Digital Ocean App Platform
- Create a new app from GitHub
- Select this repository
-
Configure environment variables:
- In your app settings, add the environment variables from your
.envfile - Set
NODE_ENVtoproduction
- In your app settings, add the environment variables from your
-
Deploy:
- Digital Ocean will automatically build and deploy your app
- SSL certificates are handled automatically
For other platforms, ensure you:
- Set environment variables in your deployment environment
- Use a process manager like PM2 for production
- Configure reverse proxy (nginx) for additional security
- Change default RPC credentials before deployment
- Use strong passwords for RPC authentication
- Enable HTTPS in production (handled automatically by Digital Ocean)
- Monitor logs for suspicious activity
- Keep dependencies updated for security patches
FairRPCAPIServer/
├── server.ts # Main server file
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env # Environment variables (not committed)
├── .gitignore # Git ignore rules
└── README.md # This file
npm start- Start production servernpm run dev- Start development server with hot reload
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -am 'Add your feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Open an issue on GitHub
- Check the FairCoin documentation
- Review server logs for error details
This software is provided as-is. Always test thoroughly in development before deploying to production. Ensure your FairCoin RPC server is properly secured and monitored.