> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/reading-account-state/quickstart.md).

# Reading account state quickstart

Read a Solana account with getAccountInfo in TypeScript, Rust or curl, then through Yellowstone Account Sync with @triton-one/triton-sdk.

In this quickstart we'll show you how to poll account state in two ways:

1. **Standard Agave polling.** You call an RPC node and it answers over the network, one request per read. Works with any standard Solana SDK, like web3.js or `@solana/kit`.
2. **Account Sync (`@triton-one/triton-sdk`)** is a drop-in for web3.js 1.x. It keeps a local copy of the accounts you track in RAM and resolves reads for those accounts against it, with no network round-trip. It auto-subscribes to each new account your code polls: RPC or the stream, whichever answers first, completes the first read, and while the account stays tracked, later reads come from memory at lower latency, and at lower cost if you read the account more often than it changes.

## 0. Prerequisites

* An active Triton subscription
* Your endpoint URL and secret token (for backends) from the [customer dashboard](https://customers.triton.one/)
* An environment in TypeScript, Rust, or curl (the Account Sync steps use TypeScript)

## 1. Install

{% tabs %}
{% tab title="Standard RPC" %}
{% tabs %}
{% tab title="TypeScript" %}

```bash
mkdir solana-reads && cd solana-reads
npm init --yes && npm pkg set type=module
npm install @solana/web3.js
npm install --save-dev typescript tsx @types/node
npx tsc --init
```

{% endtab %}

{% tab title="Rust" %}

```bash
cargo new solana-reads && cd solana-reads
```

{% code title="Cargo.toml (replace \[dependencies])" %}

```toml
[dependencies]
solana-client = "2"
solana-pubkey = "2"
anyhow = "1"
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="Account Sync" %}

```bash
mkdir account-sync && cd account-sync
npm init --yes && npm pkg set type=module
npm install @triton-one/triton-sdk
npm install --save-dev typescript tsx @types/node
npx tsc --init
```

{% endtab %}
{% endtabs %}

## 2. Connect and read

**What we're doing:** read a single account, the USDC mint. TypeScript and curl decode it with `jsonParsed`; Rust returns the raw account.

{% tabs %}
{% tab title="Standard RPC" %}
{% tabs %}
{% tab title="TypeScript" %}
{% code title="main.ts" %}

```typescript
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection(
  "https://<your-endpoint>.mainnet.rpcpool.com/<your-token>"
);

const usdcMint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const account = await connection.getParsedAccountInfo(usdcMint);

console.log(account.value);
```

{% endcode %}
{% endtab %}

{% tab title="curl" %}

```bash
curl https://<your-endpoint>.mainnet.rpcpool.com/<your-token> -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
      { "encoding": "jsonParsed" }
    ]
  }'
```

{% endtab %}

{% tab title="Rust" %}
{% code title="src/main.rs" %}

```rust
use {solana_client::rpc_client::RpcClient, solana_pubkey::Pubkey, std::str::FromStr};

fn main() -> anyhow::Result<()> {
    let client = RpcClient::new(
        "https://<your-endpoint>.mainnet.rpcpool.com/<your-token>".to_string(),
    );
    let usdc = Pubkey::from_str("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")?;
    let account = client.get_account(&usdc)?;
    println!("{:?}", account);
    Ok(())
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

For every read method and its parameters, see [Account methods](/solana/rpc-methods/readme.md).
{% endtab %}

{% tab title="Account Sync" %}
Swap `@solana/web3.js` for `@triton-one/triton-sdk`. Your polling code stays the same: the same `getParsedAccountInfo` call is answered from a local buffer fed by the stream once the account is tracked.

{% code title="main.ts" %}

```typescript
import { AccountSyncTransports, Connection, PublicKey } from "@triton-one/triton-sdk";

const usdcMint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";

const connection = new Connection(
  "https://<your-endpoint>.mainnet.rpcpool.com/<your-token>",
  {
    accountSync: {
      transport: AccountSyncTransports.GRPC, // Node backend; use AccountSyncTransports.WS in the browser
      initialAccounts: [usdcMint], // seed the accounts to stream and track
    },
  }
);

const account = await connection.getParsedAccountInfo(new PublicKey(usdcMint));
console.log(account.value);

await connection.close();
```

{% endcode %}

In Node backends, use `transport: AccountSyncTransports.GRPC`. Browsers must use `transport: AccountSyncTransports.WS`. If you omit `subscriptionEndpoint`, gRPC uses your RPC endpoint as is and WebSocket derives its URL from it. Set `subscriptionEndpoint` when your stream endpoint differs from your RPC endpoint; the [Account Sync quick start](/solana/reading-account-state/account-sync.md#quick-start) shows both URLs.
{% endtab %}
{% endtabs %}

## 3. Verify it works

Run your code:

{% tabs %}
{% tab title="TypeScript" %}

```bash
npx tsx main.ts
```

{% endtab %}

{% tab title="Rust" %}

```bash
cargo run
```

{% endtab %}

{% tab title="curl" %}
The response prints straight to your terminal.
{% endtab %}
{% endtabs %}

Then check:

1. **You got a `result`, not an `error`.** A JSON-RPC error has an `error` object with a `code`. The common ones are in [Common Solana errors](/solana/faq/error-handling/common-solana-errors.md).
2. **The account exists.** `getAccountInfo` returns `null` when the address holds no account. The USDC mint above always returns data.
3. **Account Sync only: the stream.** If the stream can't connect, reads fall back to RPC and still return a result. See [Background errors](/solana/reading-account-state/account-sync/typescript-sdk-reference.md#background-errors) for how to read stream errors.

### Expected response

In `result.value` you'll see the USDC mint object, decoded with `jsonParsed`. The block below is `result.value` from curl. In TypeScript, `owner` is a `PublicKey`. In the Standard RPC tab (`@solana/web3.js` 3.x), `lamports`, `space` and `rentEpoch` print as bigint, for example `82n`, and `console.log` shows nested objects such as `info` as `[Object]`. Rust prints the raw account instead: `lamports`, `data.len`, `owner`, `executable`, `rent_epoch`, and the first 64 bytes of `data` as hex. Live values like `supply` and `lamports` will differ when you run it.

```json
{
  "data": {
    "parsed": {
      "info": {
        "decimals": 6,
        "freezeAuthority": "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar",
        "isInitialized": true,
        "mintAuthority": "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG",
        "supply": "7957814436632629"
      },
      "type": "mint"
    },
    "program": "spl-token",
    "space": 82
  },
  "executable": false,
  "lamports": 511210011619,
  "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  "rentEpoch": 18446744073709551615,
  "space": 82
}
```

## What's next

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-arrows-rotate">:arrows-rotate:</i> <strong>Account Sync</strong></td><td>Streaming-backed local cache for faster and cheaper account reads, via the web3.js-compatible SDK.</td><td><a href="/solana/reading-account-state/account-sync.md">Account Sync</a></td></tr><tr><td><i class="fa-database">:database:</i> <strong>Cloudbreak Accounts</strong></td><td>getProgramAccounts and SPL token account queries served from indexes built automatically from real query traffic.</td><td><a href="/solana/reading-account-state/cloudbreak-indexed-accounts.md">Cloudbreak Accounts</a></td></tr><tr><td><i class="fa-image">:image:</i> <strong>Metaplex DAS API</strong></td><td>Query NFTs, tokens, and compressed assets via the Digital Asset Standard interface.</td><td><a href="/solana/reading-account-state/metaplex-das-api.md">Metaplex DAS API</a></td></tr><tr><td><i class="fa-compass">:compass:</i> <strong>Streaming overview</strong></td><td>Compare every Triton streaming service and choose the right fit for your workload.</td><td><a href="/solana/real-time-streaming.md">Real-time streaming</a></td></tr></tbody></table>

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
