> ## Documentation Index
> Fetch the complete documentation index at: https://grat.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Sponsor your first transaction in under 10 minutes.

Get started with Grat by setting up a local relay and sponsoring a testnet transaction.

### Prerequisites

* [Docker](https://docs.docker.com/get-docker/) installed and running.
* [Node.js 20+](https://nodejs.org/) and a package manager (npm, yarn, or pnpm).

<Steps>
  <Step title="Start the Relay">
    To sponsor transactions, you need a running Grat Relay.

    #### Option A: One-Click Cloud Deploy (Recommended)

    Deploy a private relay to **Render** in minutes. This provides an instant HTTPS endpoint for your web apps.

    <a href="https://render.com/deploy?repo=https://github.com/gratnetwork/grat">
      <img src="https://render.com/images/deploy-to-render-button.svg" alt="Deploy to Render" />
    </a>

    #### Option B: Local Docker

    If you prefer to run it locally:

    ```bash theme={null}
    git clone https://github.com/gratnetwork/grat.git
    cd grat
    docker-compose up -d
    ```

    The relay will automatically fund its internal channel accounts using the Stellar Friendbot when running in testnet mode.
  </Step>

  <Step title="Install the SDK">
    In your project directory, install the official TypeScript SDK.

    <CodeGroup>
      ```bash npm theme={null}
      npm install @grat-official-sdk/sdk
      ```

      ```bash yarn theme={null}
      yarn add @grat-official-sdk/sdk
      ```

      ```bash pnpm theme={null}
      pnpm add @grat-official-sdk/sdk
      ```
    </CodeGroup>
  </Step>

  <Step title="Sponsor your first Transaction">
    Create a file named `sponsor.ts` and add the following code. This script builds a simple XLM payment on the testnet and sends it to the Grat relay for sponsorship.

    ```typescript theme={null}
    import { Grat } from '@grat-official-sdk/sdk';
    import { Keypair, Asset, TransactionBuilder, Networks, Operation } from '@stellar/stellar-sdk';

    async function main() {
      // 1. Initialize the Grat client for testnet
      const grat = Grat.testnet();

      // 2. Create a test account (the user)
      const userKp = Keypair.random();
      
      // 3. Build a simple XLM payment transaction
      // Note: In a real app, you would load the account to get the current sequence number
      const tx = new TransactionBuilder(
        { publicKey: userKp.publicKey(), sequence: "1" },
        { fee: "100", networkPassphrase: Networks.TESTNET }
      )
      .addOperation(Operation.payment({
        destination: "GDQP237HAYA6AK3AOTK2S3SFSBCS3KZ766XJH5Y6S6TORYS6A7XNQLS6",
        asset: Asset.native(),
        amount: "10"
      }))
      .setTimeout(30)
      .build();

      // 4. Sign the transaction with the user's keypair
      tx.sign(userKp);

      // 5. Sponsor and submit via Grat
      console.log("Sponsoring transaction...");
      const result = await grat.sponsor(tx);

      console.log("Success! Transaction hash:", result.hash);
    }

    main();
    ```
  </Step>

  <Step title="Verify it Worked">
    Copy the transaction hash from your console and search for it on [Stellar Expert (Testnet)](https://stellar.expert/explorer/testnet). You will see that the transaction was successful and that a fee-bump envelope was used to pay the network fee.
  </Step>
</Steps>

<Tip>
  Ready for something more realistic? Check out our guide on [Sponsoring USDC Payments](/guides/sponsor-usdc-payments) to see how to handle trustlines and asset transfers.
</Tip>

[View on GitHub](https://github.com/gratnetwork/grat)
