---
title: "2. Gateway SDK: Reading Ledger State"
path: "/developers/frontend/02-gateway-sdk"
version: "1.1.0"
author: "Hydrate"
createdAt: "2026-02-22T17:58:00.655Z"
updatedAt: "2026-03-16T18:21:03.462Z"
---

# 2. Gateway SDK: Reading Ledger State

<Infobox>
| **Gateway SDK** |
| Difficulty | Intermediate |
| Est. Time | 20 minutes |
| Prerequisites | [Radix dApp Toolkit](/developers/frontend/01-radix-dapp-toolkit) |
| Language | TypeScript |
| NPM | [@radixdlt/babylon-gateway-api-sdk](https://www.npmjs.com/package/@radixdlt/babylon-gateway-api-sdk) |
</Infobox>

## Overview

The [Gateway SDK](/developers/legacy-docs/build/build-dapps/dapp-application-stack/dapp-sdks/gateway-sdk) is a TypeScript client for the [Radix Gateway API](/developers/infrastructure/02-radix-apis). It lets you query account balances, read component state, look up transaction history, and submit transactions — all the read/write operations your dApp frontend needs.

`npm install @radixdlt/babylon-gateway-api-sdk`

## Setup

```typescript
import { GatewayApiClient, RadixNetwork } from '@radixdlt/babylon-gateway-api-sdk'

const gatewayApi = GatewayApiClient.initialize({
  networkId: RadixNetwork.Mainnet,  // or RadixNetwork.Stokenet
  applicationName: 'My dApp',
  applicationVersion: '1.0.0',
  applicationDappDefinitionAddress: 'account_rdx...'
})
```
The SDK connects to the [Radix Foundation](/ecosystem/radix-foundation)'s public Gateway by default. For production dApps with high traffic, consider running your own [Gateway node](/developers/infrastructure/02-radix-apis) or using a third-party provider.

## Common Queries

### Account Balances

```typescript
const details = await gatewayApi.state.getEntityDetailsVaultAggregated(
  'account_rdx1c956...'  // account address
)
// details.fungible_resources — token balances
// details.non_fungible_resources — NFT holdings
```
### Component State

```typescript
const component = await gatewayApi.state.getEntityDetailsVaultAggregated(
  'component_rdx1cp...'  // component address
)
// Read state, [vaults](https://docs.radixdlt.com/docs/resources-and-data), metadata
```
### Entity Metadata

```typescript
const metadata = await gatewayApi.state.getAllEntityMetadata(
  'resource_rdx1t...'  // any entity address
)
// Returns: name, symbol, description, icon_url, etc.
```

### Transaction Status

```typescript
const status = await gatewayApi.transaction.getStatus(
  'txid_rdx1...'  // intent hash from sendTransaction
)
// status.intent_status: "CommittedSuccess" | "CommittedFailure" | "Pending" | ...
```
### Historical State

Query state at a specific point in time by passing `at_ledger_state`:

```typescript
const historicalDetails = await gatewayApi.state.innerClient.stateEntityDetails({
  stateEntityDetailsRequest: {
    addresses: ['account_rdx1...']
    at_ledger_state: { state_version: 12345678 }
  }
})
```

## External Links

- [@radixdlt/babylon-gateway-api-sdk on npm](https://www.npmjs.com/package/@radixdlt/babylon-gateway-api-sdk)
- [Gateway API reference](https://radix-babylon-gateway-api.redoc.ly/)
- [Mainnet Gateway Swagger UI](https://mainnet.radixdlt.com/swagger/)