Grat is designed to be self-hostable, giving you full control over your sponsorship infrastructure, channel accounts, and security policies.Documentation Index
Fetch the complete documentation index at: https://grat.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js 20+: The relay is built with TypeScript and Node.js.
- Docker & Docker Compose: Recommended for production deployments.
- Redis: Used for channel locking and sequence number management.
- PostgreSQL: Used for persistent storage of API keys and logs.
- Stellar Account: At least one funded Stellar account to act as a fee channel.
Deployment with Docker
The fastest way to deploy Grat is using the provided Docker Compose configuration.Update Environment Variables
Edit the
.env file to include your database credentials, Redis URL, and Stellar configurations. See the variables table below for details.Environment Variables
| Variable | Description | Default |
|---|---|---|
PORT | The port the relay server listens on. | 3000 |
NETWORK | testnet or mainnet. | testnet |
RPC_URL | The URL of your Stellar RPC provider. | Required |
DATABASE_URL | PostgreSQL connection string. | postgresql://... |
REDIS_URL | Redis connection string. | redis://... |
CHANNEL_COUNT | Number of parallel fee channels to maintain. | 10 |
CHANNEL_SEED_PHRASE | Mnemonic for deriving channel accounts. | Required |
ADMIN_TOKEN | Token for administrative API access. | Required |
DEPOSIT_ADDRESS | Stellar address to receive credit deposits. | Optional |
DEPOSIT_POLL_INTERVAL_MS | Frequency to poll for new deposits. | 5000 |
FEE_MULTIPLIER | Multiplier for base fees on classic transactions. | 1.5 |
Stellar requires an RPC provider for mainnet access. The SDF does not host a free mainnet RPC endpoint. We recommend using a professional provider such as Quicknode, Blockdaemon, or Validation Cloud. For testnet, you can use the SDF’s free testnet RPC at
https://soroban-testnet.stellar.org.Channel Account Management
Channels are the backbone of the relay. They provide the sequence numbers and XLM needed to pay for sponsored transactions.- Creation: Grat derives channel accounts from a single seed phrase using BIP39.
- Funding: In production, you must fund these accounts with enough XLM to cover your expected transaction volume.
- Monitoring: The
/healthendpoint provides data on individual channel balances and availability.
Cloud Platforms
Railway
Railway
- Connect your GitHub repo.
- Add PostgreSQL and Redis plugins.
- Configure environment variables in the Railway dashboard.
- Deploy.
Render
Render
- Create a “Web Service” from your repo.
- Create managed PostgreSQL and Redis instances.
- Link environment variables.
- Set the build command to
npm run buildand start command tonpm start.
Fly.io
Fly.io
- Run
fly launchto initialize the project. - Provisions DB and Redis via Fly’s extensions.
- Set secrets using
fly secrets set. - Deploy using the included Dockerfile.
Monitoring and Metrics
Grat exposes a/metrics endpoint compatible with Prometheus. You can monitor:
- Request counts and latency.
- Active vs locked channel accounts.
- Success vs failure rates for sponsored submissions.
- Total XLM spent across all channels.
Managed cloud hosting is coming soon for teams who prefer zero infrastructure overhead. Join our newsletter to be notified when we launch.