A lightweight production-ready Express.js server that demonstrates how to integrate with the Chainrails SDK to generate secure session tokens for cross-chain transactions. This demo server handles session creation for Chainrails.
- Express.js Server: Fast and lightweight HTTP server
- CORS Support: Configurable cross-origin resource sharing
- Environment Configuration: Flexible setup with environment variables
- Session Token Generation: Secure token creation via Chainrails SDK
- Vercel Deployment Ready: Pre-configured for serverless deployment
- Node.js >= 16.x
- Chainrails API Key - Get it from Chainrails Dashboard
git clone https://github.com/horuslabsio/chainrails-session-server-demo
cd chainrails-session-server-demoOr using npm:
npm installCreate a .env file in the root directory:
# Chainrails API Configuration
CHAINRAILS_API_KEY=your_api_key_here
# CORS Configuration
CHAINRAILS_DOMAIN_WHITELIST=http://localhost:3000,https://yourdomain.com| Variable | Required | Description |
|---|---|---|
CHAINRAILS_API_KEY |
✅ | Your Chainrails API key for authentication |
PORT |
❌ | Server port (default: 4000) |
CHAINRAILS_DOMAIN_WHITELIST |
❌ | Comma-separated list of allowed origins for CORS |
npm startThe server will start on http://localhost:4000
The project includes a vercel.json configuration file for easy deployment to Vercel.
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard:
CHAINRAILS_API_KEYCHAINRAILS_DOMAIN_WHITELIST
- Always keep your
CHAINRAILS_API_KEYsecret and never commit it to version control