Public REST API proxy for Hoosat blockchain built with NestJS and hoosat-sdk.
- Features
- Prerequisites
- Installation
- Configuration
- Running the App
- API Documentation
- Available Endpoints
- Response Format
- Examples
- Development
- Testing
- Deployment
- Docker
- Contributing
- License
- β RESTful API for all Hoosat blockchain operations
- β
Swagger Documentation at
/docs - β Standardized responses with success/error format
- β Environment-based configuration
- β Health checks for monitoring
- β Global error handling
- β Request validation with class-validator
- β TypeScript for type safety
- β Production ready
- Node.js 18.x or 20.x
- npm or yarn
- Hoosat Node (local or remote) - Get Hoosat Node
# Clone the repository
git clone https://github.com/Namp88/hoosat-proxy.git
cd hoosat-proxy
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env
# Edit .env with your Hoosat node settings
nano .env # or your favorite editorEdit .env file:
# Server
PORT=3000
# Hoosat Node
HOOSAT_HOST=127.0.0.1 # Your Hoosat node host
HOOSAT_PORT=42420 # Your Hoosat node port
HOOSAT_TIMEOUT=10000
# API
API_PREFIX=api
API_VERSION=v1# Development
npm run start:dev
# Production
npm run build
npm run start:prodOnce the server is running, visit:
- Swagger UI: http://localhost:3000/docs
- API Base URL: http://localhost:3000/api/v1
GET /api/v1/node/info- Get node informationGET /api/v1/node/blue-score- Get virtual selected parent blue scoreGET /api/v1/node/estimate-hashrate- Estimate network hashrateGET /api/v1/node/coin-supply- Get coin supply informationGET /api/v1/node/health- Health check
GET /api/v1/blockchain/tip-hash- Get selected tip hashGET /api/v1/blockchain/block/:hash- Get block by hashGET /api/v1/blockchain/blocks?lowHash=...- Get multiple blocksGET /api/v1/blockchain/count- Get block countGET /api/v1/blockchain/dag-info- Get DAG information
GET /api/v1/network/info- Get current networkGET /api/v1/network/peers- Get peer addressesGET /api/v1/network/connected-peers- Get connected peers info
GET /api/v1/address/:address/balance- Get address balancePOST /api/v1/address/balances- Get multiple address balancesPOST /api/v1/address/utxos- Get UTXOs by addresses
GET /api/v1/mempool/entry/:txId- Get mempool entry by transaction IDGET /api/v1/mempool/entries- Get all mempool entriesPOST /api/v1/mempool/entries-by-addresses- Get entries by addressesGET /api/v1/mempool/fee-estimate- Get fee estimate
POST /api/v1/transaction/submit- Submit signed transactionGET /api/v1/transaction/:txId/status- Get transaction status (PENDING/CONFIRMED/NOT_FOUND)
All endpoints return responses in this format:
{
"success": true,
"data": {
// Response data
},
"timestamp": "2025-01-10T12:00:00.000Z",
"path": "/api/v1/node/info"
}Error responses:
{
"success": false,
"error": "Error message",
"timestamp": "2025-01-10T12:00:00.000Z",
"path": "/api/v1/node/info"
}# Build the application
npm run build
# Start production server
npm run start:prod# Install PM2 globally
npm install -g pm2
# Start with PM2
pm2 start dist/main.js --name hoosat-proxy
# Save PM2 configuration
pm2 save
# Setup PM2 startup script
pm2 startupMake sure to set appropriate values in your production .env:
# Use production Hoosat node
HOOSAT_HOST=your-production-node.com
HOOSAT_PORT=42420
# Adjust timeouts for production
HOOSAT_TIMEOUT=15000
# Set production port
PORT=3000Build and run with Docker:
# Build Docker image
docker build -t hoosat-proxy .
# Run container
docker run -d \
-p 3000:3000 \
-e HOOSAT_HOST=your-node-host \
-e HOOSAT_PORT=42420 \
--name hoosat-proxy \
hoosat-proxy
# View logs
docker logs -f hoosat-proxyOr use Docker Compose:
# Start with docker-compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose downcurl http://localhost:3000/api/v1/node/infocurl "http://localhost:3000/api/v1/node/hashrate?windowSize=1000"curl http://localhost:3000/api/v1/blockchain/block/BLOCK_HASHcurl http://localhost:3000/api/v1/address/hoosat:qz7ulu.../balancecurl -X POST http://localhost:3000/api/v1/address/utxos \
-H "Content-Type: application/json" \
-d '{"addresses": ["hoosat:qz7ulu...", "hoosat:qyp4ka..."]}'curl http://localhost:3000/api/v1/mempool/entriescurl -X POST http://localhost:3000/api/v1/transaction/submit \
-H "Content-Type: application/json" \
-d '{
"version": 0,
"inputs": [...],
"outputs": [...],
"lockTime": "0",
"subnetworkId": "0000000000000000000000000000000000000000",
"gas": "0",
"payload": ""
}'curl "http://localhost:3000/api/v1/transaction/abc123def456.../status?senderAddress=hoosat:qzsender...&recipientAddress=hoosat:qzrecipient..."Response example (PENDING):
{
"success": true,
"data": {
"status": "PENDING",
"details": {
"txId": "abc123def456...",
"inMempool": true,
"isOrphan": false,
"fee": "1000000",
"mass": "250",
"message": "Transaction is in mempool, waiting for confirmation"
}
},
"timestamp": "2025-01-10T12:00:00.000Z",
"path": "/api/v1/transaction/abc123def456.../status"
}Response example (CONFIRMED):
{
"success": true,
"data": {
"status": "CONFIRMED",
"details": {
"txId": "abc123def456...",
"inMempool": false,
"blockDaaScore": "123456",
"confirmedAmount": "50000000",
"confirmedAddress": "hoosat:qzrecipient456...",
"isCoinbase": false,
"message": "Transaction confirmed in blockchain"
}
},
"timestamp": "2025-01-10T12:00:00.000Z",
"path": "/api/v1/transaction/abc123def456.../status"
}Response example (NOT_FOUND):
{
"success": true,
"data": {
"status": "NOT_FOUND",
"details": {
"txId": "abc123def456...",
"inMempool": false,
"message": "Transaction not found in mempool or UTXOs. Possible reasons: transaction was rejected, UTXOs already spent, or node does not have UTXO index enabled (--utxoindex flag)"
}
},
"timestamp": "2025-01-10T12:00:00.000Z",
"path": "/api/v1/transaction/abc123def456.../status"
}Note: Node must be started with --utxoindex flag for CONFIRMED status detection.
curl http://localhost:3000/api/v1/node/health# Generate new module
nest g module modules/your-module
nest g controller modules/your-module
nest g service modules/your-module
# Format code
npm run format
# Lint code
npm run lintContributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Hoosat SDK - TypeScript SDK for Hoosat blockchain
- Hoosat Node (HTND) - Official Hoosat node implementation
- Hoosat Website - Official Hoosat project website
- Documentation - Hoosat documentation
Made with β€οΈ by the Hoosat community