A high-performance Solana RPC proxy server that intercepts deprecated methods and forwards requests to Helius RPC for better reliability and performance.
- ✅ Deprecated Method Support: Automatically handles
getRecentBlockhashcalls by converting them togetLatestBlockhash - ✅ Helius RPC Integration: Uses Helius RPC for improved performance and reliability
- ✅ Smart Fee Calculation: Dynamically calculates transaction fees using recent prioritization fees
- ✅ Request Validation: Validates JSON-RPC 2.0 format and required fields
- ✅ Security Headers: Includes standard security headers
- ✅ Health Check Endpoint: Monitor server and Solana network status
- ✅ Graceful Shutdown: Handles shutdown signals properly
- ✅ Environment Configuration: Configurable via environment variables
- ✅ CORS Support: Configurable CORS settings
-
Clone or download this project
-
Install dependencies:
npm install
-
Copy the environment example file:
copy .env.example .env
-
Update your
.envfile with your Helius API key:HELIUS_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY_HERE PORT=3001 NODE_ENV=development
npm run devnpm startThe server will start on the port specified in your .env file (default: 3001).
- URL:
POST / - Purpose: Handles all Solana RPC requests
- Special Handling: Converts
getRecentBlockhashto usegetLatestBlockhash
- URL:
GET /health - Purpose: Check server and Solana network status
- Response: Current slot, timestamp, and connection status
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3001 |
NODE_ENV |
Environment mode | development |
HELIUS_RPC_URL |
Helius RPC endpoint with API key | Required |
ALLOWED_ORIGINS |
Comma-separated CORS origins | All origins allowed |
To restrict CORS origins, set the ALLOWED_ORIGINS environment variable:
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.comconst response = await fetch("http://localhost:3001", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getRecentBlockhash",
}),
});
const data = await response.json();
console.log(data.result.value.blockhash);const response = await fetch("http://localhost:3001", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getAccountInfo",
params: ["YOUR_ACCOUNT_ADDRESS"],
}),
});const health = await fetch("http://localhost:3001/health");
const status = await health.json();
console.log(status);- Helius RPC Integration: Now uses your Helius RPC endpoint for better performance
- Enhanced Fee Calculation: Uses recent prioritization fees for more accurate fee estimation
- Request Validation: Validates JSON-RPC format and required fields
- Security Headers: Added standard security headers
- Error Handling: Improved error messages and logging
- Environment Configuration: Configurable via environment variables
- Health Check: Added health monitoring endpoint
- Graceful Shutdown: Proper signal handling
- CORS Configuration: Configurable CORS settings
- Documentation: Added comprehensive documentation
- The server uses Helius RPC which provides better reliability and performance than standard Solana RPC nodes
- Fee calculations now use recent prioritization fees for more accurate estimates
- Request validation happens early to reject invalid requests quickly
- Connection reuse and proper timeout settings for optimal performance
- API keys are masked in logs and health check responses
- CORS can be restricted to specific origins
- Security headers are included in all responses
- Request size is limited to prevent abuse
- Input validation prevents malformed requests