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

# Quickstart Guide

> Get started with Yellowstone gRPC streaming in minutes — install a client, authenticate, and subscribe to live Solana slots, blocks, and transactions.

## What is Yellowstone gRPC?

Yellowstone gRPC provides direct access to Solana blockchain data through high-performance streaming. Unlike traditional RPC polling, gRPC delivers real-time updates with minimal latency, making it ideal for:

* **Trading Bots** - Execute trades faster with real-time data
* **DeFi Applications** - Monitor liquidity pools and token swaps instantly
* **Analytics Platforms** - Track on-chain activity as it happens
* **Arbitrage Systems** - Detect opportunities with millisecond precision

## Quick Start

<Steps>
  <Step title="Subscribe to Yellowstone gRPC">
    Subscribe to the gRPC service at **\$247/month**:

    [Subscribe to Yellowstone gRPC](https://www.solanatracker.io/solana-rpc)

    **What you get:**

    * **Two Regional Endpoints:**
      * EU Region: `https://grpc.solanatracker.io`
      * US Region: `https://grpc-us.solanatracker.io`
    * **Jito Shreds** - 50-100ms faster data delivery
    * **No Bandwidth Charges** - Unlimited data streaming
    * **24/7 Uptime** - Automatic failover and monitoring

    <Note>
      Choose the endpoint closest to your infrastructure for optimal performance. Co-locate in the same data center for sub-millisecond latency.
    </Note>
  </Step>

  <Step title="Get Your API Credentials">
    After subscribing, retrieve your authentication credentials:

    [Get Your API Token](https://www.solanatracker.io/account/rpc)

    You'll receive:

    * **x-token** - Your authentication token for gRPC requests
    * **Endpoint URLs** - Both EU and US regions
    * **Configuration Guidelines** - Recommended settings

    <Warning>
      **Keep your token secure!**

      * Never commit tokens to version control
      * Use environment variables
      * Rotate tokens periodically
    </Warning>
  </Step>

  <Step title="Install Dependencies">
    Install the Yellowstone gRPC client:

    ```bash theme={null}
    npm install @triton-one/yellowstone-grpc
    ```
  </Step>
</Steps>

## Complete Working Example

Here's a complete, production-ready example that monitors transactions:

```javascript theme={null}
const Client = require("@triton-one/yellowstone-grpc").default;
const { CommitmentLevel } = require("@triton-one/yellowstone-grpc");

// Initialize and connect to Yellowstone gRPC
const getClient = async () => {
  let client = false;
  try {
    client = new Client(
      "https://grpc.solanatracker.io",
      "your-api-key-here",
      {
        "grpc.max_receive_message_length": 100 * 1024 * 1024,
      }
    );
    const version = await client.getVersion();
    if (version) {
      console.log("Connected! Version:", version);
      return client;
    }
  } catch (e) {
    console.error("Failed to connect:", e);
  }
  if (!client) {
    throw new Error("Failed to connect!");
  }
};

(async () => {
  const client = await getClient();
  const stream = await client.subscribe();

  // Handle stream lifecycle
  const streamClosed = new Promise((resolve, reject) => {
    stream.on("error", (error) => {
      console.error("Stream error:", error);
      reject(error);
    });
    stream.on("end", () => {
      console.log("Stream ended");
      resolve();
    });
    stream.on("close", () => {
      console.log("Stream closed");
      resolve();
    });
  });

  // Handle incoming data
  stream.on("data", (data) => {
    if (data?.transaction) {
      const tx = data.transaction.transaction;
      console.log("\n[Transaction]");
      console.log("  Signature:", tx.signature);
      console.log("  Slot:", data.transaction.slot);
      console.log("  Success:", !tx.meta?.err);
      if (tx.meta?.fee) {
        console.log("  Fee:", (tx.meta.fee / 1e9).toFixed(6), "SOL");
      }
    }
  });

  // Subscribe to Token Program transactions
  const request = {
    accounts: {},
    slots: {},
    transactions: {
      tokenTransactions: {
        vote: false,
        failed: false,
        signature: undefined,
        accountInclude: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
        accountExclude: [],
        accountRequired: [],
      },
    },
    transactionsStatus: {},
    entry: {},
    blocks: {},
    blocksMeta: {},
    accountsDataSlice: [],
    ping: undefined,
    commitment: CommitmentLevel.CONFIRMED,
  };

  // Send subscribe request
  await new Promise((resolve, reject) => {
    stream.write(request, (err) => {
      if (err === null || err === undefined) {
        console.log("Subscribed to Token Program transactions");
        resolve();
      } else {
        reject(err);
      }
    });
  }).catch((reason) => {
    console.error("Subscribe failed:", reason);
    throw reason;
  });

  await streamClosed;
})();
```

## What This Example Does

1. **Connects to Yellowstone gRPC** with proper error handling
2. **Creates a stream** with lifecycle event handlers
3. **Subscribes to transactions** involving the Token Program
4. **Processes each transaction** and logs key details
5. **Handles errors gracefully** with proper cleanup

## Monitoring Different Data Types

<Tabs>
  <Tab title="Account Updates">
    **Monitor account changes:**

    ```javascript theme={null}
    const request = {
      accounts: {
        myAccounts: {
          account: ["YourAccountAddress"],
          owner: [],
          filters: []
        }
      },
      slots: {},
      transactions: {},
      transactionsStatus: {},
      entry: {},
      blocks: {},
      blocksMeta: {},
      accountsDataSlice: [],
      ping: undefined,
      commitment: CommitmentLevel.CONFIRMED,
    };

    stream.on("data", (data) => {
      if (data?.account) {
        const account = data.account.account;
        console.log("Account Update:", account.pubkey);
        console.log("Lamports:", account.lamports);
      }
    });
    ```
  </Tab>

  <Tab title="Slot Updates">
    **Monitor network slots:**

    ```javascript theme={null}
    const request = {
      accounts: {},
      slots: {
        slotSubscribe: {}
      },
      transactions: {},
      transactionsStatus: {},
      entry: {},
      blocks: {},
      blocksMeta: {},
      accountsDataSlice: [],
      ping: undefined,
      commitment: CommitmentLevel.CONFIRMED,
    };

    stream.on("data", (data) => {
      if (data?.slot) {
        console.log("Slot:", data.slot.slot);
        console.log("Parent:", data.slot.parentSlot);
        console.log("Status:", data.slot.status);
      }
    });
    ```
  </Tab>

  <Tab title="Block Data">
    **Monitor blocks:**

    ```javascript theme={null}
    const request = {
      accounts: {},
      slots: {},
      transactions: {},
      transactionsStatus: {},
      entry: {},
      blocks: {},
      blocksMeta: {
        blockMetaSubscribe: {}
      },
      accountsDataSlice: [],
      ping: undefined,
      commitment: CommitmentLevel.CONFIRMED,
    };

    stream.on("data", (data) => {
      if (data?.blockMeta) {
        console.log("Block:", data.blockMeta.slot);
        console.log("Transactions:", data.blockMeta.transactionCount);
        console.log("Block Hash:", data.blockMeta.blockhash);
      }
    });
    ```
  </Tab>
</Tabs>

## Environment Variables

Store your credentials securely:

```bash theme={null}
# .env file
GRPC_ENDPOINT=https://grpc.solanatracker.io
GRPC_API_KEY=your-api-key-here
```

```javascript theme={null}
require('dotenv').config();

const client = new Client(
  process.env.GRPC_ENDPOINT,
  process.env.GRPC_API_KEY,
  {
    "grpc.max_receive_message_length": 100 * 1024 * 1024,
  }
);
```

## What's Next?

<CardGroup cols={2}>
  <Card title="Transaction Monitoring" icon="receipt" href="/yellowstone-grpc/transaction-monitoring">
    Monitor DEX transactions and program activity
  </Card>

  <Card title="Account Monitoring" icon="user" href="/yellowstone-grpc/account-monitoring">
    Track token holders and account changes
  </Card>

  <Card title="Pump.fun Example" icon="chart-line" href="/yellowstone-grpc/examples/pumpfun-transactions">
    Build a Pump.fun trading bot
  </Card>

  <Card title="Best Practices" icon="star" href="/yellowstone-grpc/best-practices">
    Optimize for production
  </Card>
</CardGroup>

## Common Questions

### Which endpoint should I use?

**Choose based on your location:**

* **Europe/Global:** `https://grpc.solanatracker.io`
* **North America:** `https://grpc-us.solanatracker.io`

Test both endpoints and use the one with lower latency from your deployment region. Aim for \~1ms latency by co-locating in the same data center.

### How do I handle reconnections?

Wrap your connection logic in a retry function:

```javascript theme={null}
async function connectWithRetry(maxRetries = 5) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await getClient();
    } catch (e) {
      console.log(`Retry ${i + 1}/${maxRetries}...`);
      await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, i)));
    }
  }
  throw new Error("Max retries exceeded");
}
```

### What commitment level should I use?

**Commitment levels:**

* **PROCESSED** - Fastest, but can be rolled back
* **CONFIRMED** - Balanced speed and finality (recommended)
* **FINALIZED** - Slowest, but guaranteed finalized

For most applications, `CONFIRMED` is the best choice.

### How do I filter transactions?

Use the filter fields in your subscribe request:

```javascript theme={null}
transactions: {
  myTransactions: {
    vote: false,                    // Exclude vote transactions
    failed: false,                  // Exclude failed transactions
    accountInclude: ["Address1"],   // Must include any of these (OR)
    accountRequired: ["Address2"],  // Must include all of these (AND)
    accountExclude: ["Address3"],   // Must not include any of these
  }
}
```

## Support & Resources

<CardGroup cols={2}>
  <Card title="Support" icon="headset">
    Get help with your implementation

    [support@solanatracker.io](mailto:support@solanatracker.io)
  </Card>

  <Card title="Yellowstone gRPC Source" icon="github">
    Complete protobuf definitions and protocol specs

    [View Repository](https://github.com/rpcpool/yellowstone-grpc)
  </Card>
</CardGroup>
