Eliminate the "XLM for Gas" problem and onboard users to Stellar with zero friction.
Stellar transactions require XLM to pay for network fees. For many users, especially those only interested in stablecoins (like USDC), acquiring XLM is a high-friction barrier to entry.
Grat is a relay server and SDK that implements Gas Abstraction. It allows developers to sponsor the transaction fees for their users by wrapping transactions in fee-bump envelopes. With Grat, your users can hold USDC and perform operations without ever needing to touch or even know about XLM. Try the Live Demo
Compatible with Protocol 26 (Yardstick), including all new Soroban host functions, precise TTL extensions, and frozen ledger entry handling.
Deploy your own private relay to the cloud in minutes:
Clone the repo and start the local stack in under 2 minutes:
git clone https://github.com/gratnetwork/grat.git
cd grat
cp .env.example .env
# Open .env and add your STELLAR_FUNDING_SECRET
docker-compose up -dnpm install @grat-official-sdk/sdkimport { Grat } from '@grat-official-sdk/sdk';
const grat = Grat.testnet(); // Defaults to http://localhost:3000
const result = await grat.sponsor(signedUserTransaction);
console.log(`Success! Sponsored Hash: ${result.hash}`);Grat leverages Stellar's native Fee-Bump Transactions (CAP-0015).
- The user signs a standard transaction (the "inner" transaction).
- The SDK sends this to the Grat Relay.
- The Relay selects an available Channel Account from a pre-funded pool.
- The Relay wraps the inner transaction in a Fee-Bump envelope, signs it with the channel account, and submits it to the network via Stellar RPC.
- Deep Error Diagnostics: If a transaction fails, Grat drills down into the inner results to expose the exact operation error (e.g.,
op_low_reserve,op_no_issuer), saving developers hours of debugging. - Redis-backed sequence management ensures high concurrency without sequence conflicts across multiple instances.
- Protocol 26 (Yardstick) Ready: Fully supports Stellar RPC from day one, handling all new Soroban host functions, precise TTL extensions, and frozen ledger entry rejections (CAP-0077) with distinct error codes.
| Method | Description |
|---|---|
sponsor(tx) |
Wraps a signed transaction and submits it. Returns { hash, ledger, feePaid }. |
simulate(tx) |
Performs Soroban simulation via the relay to return resource estimates. |
estimate(tx) |
Predicts the total fee (inclusion + resource) for a transaction. |
status() |
Returns relay health, network info, and channel pool statistics. |
Sponsor a classic or Soroban transaction.
- Body:
{ "transaction": "BASE64_XDR", "network": "testnet" } - Headers:
X-Idempotency-Key(Optional, recommended) - Response:
200 OKwithSponsorResponseobject.
Simulate a Soroban transaction to get execution footprints and resource costs. Works for both classic and Soroban transactions (classic returns zero costs).
- Body:
{ "transaction": "BASE64_XDR" }
Grat is designed to be horizontally scalable and production-ready.
RPC_URL: URL of your Stellar RPC provider (Default:https://soroban-testnet.stellar.org).STELLAR_FUNDING_SECRET: Master key used to fund and create the channel pool.CHANNEL_SEED_PHRASE: 12-word BIP39 mnemonic or secret used to derive channel keys.CHANNEL_COUNT: Number of accounts in the pool (Default:10).REDIS_URL: URL for Redis (Required for locking and sequence tracking).DATABASE_URL: PostgreSQL connection string (Required for transaction logging).NETWORK:testnetormainnet.
Explore the examples/ directory for production-ready blueprints:
- USDC Transfer: Complete lifecycle (Trustline -> Mint -> Payment) with zero XLM fees. Live Demo
- Soroban Call: Sponsor smart contract interactions and Soroban resource fees.
- Trustline Setup: One-click onboarding for new Stellar users.
pnpm install
pnpm test:unit # Run SDK unit tests
pnpm test:integration # Run Server integration tests against testnet
pnpm smoke-test # Run end-to-end network validationGrat has completed its Phase 1 milestone. All core gas-abstraction features for both Stellar Classic and Soroban are implemented, tested, and verified on Testnet.
- Classic Transaction Sponsorship
- Soroban Resource Fee Sponsorship
- Distributed Sequence Management
- High-Concurrency Channel Pool
- Deep Error Diagnostics
- Multi-platform SDK (TypeScript)
- Protocol 26 (Yardstick) Compatibility
We welcome contributions! Please check the Contributing Guide and our Code of Conduct.
- Twitter: @gratnetworkHq
- Email: gratnetworkofficial@gmail.com
- GitHub: gratnetwork/grat
Apache 2.0 © Grat Network
