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

# Helius TypeScript SDK untuk Agen

> Panduan lengkap untuk Helius TypeScript SDK bagi agen AI — metode Solana yang aman secara tipe untuk DAS API, transaksi, Sender, webhook, dan ZK Compression.

[Helius TypeScript SDK](https://github.com/helius-labs/helius-sdk) menyediakan metode yang aman secara tipe untuk semua API Helius, sehingga menjadi cara tercepat bagi agen untuk berinteraksi dengan Solana.

* **Paket**: `helius-sdk` (npm / pnpm / yarn)
* **Versi**: 2.x (menggunakan `@solana/kit`, bukan `@solana/web3.js`)
* **Runtime**: Runtime JavaScript apa pun — browser, Deno, Bun, runtime edge (Cloudflare Workers, Vercel Edge), Node.js 20+
* **TypeScript**: 5.8+ (definisi tipe lengkap disertakan)
* **Lisensi**: ISC

## Instalasi

```bash theme={"system"}
npm install helius-sdk
```

## Mulai Cepat

```typescript theme={"system"}
import { createHelius } from "helius-sdk";

const helius = createHelius({
  apiKey: "YOUR_API_KEY",
  network: "mainnet", // or "devnet"
});

// Get all NFTs and tokens owned by a wallet
const assets = await helius.getAssetsByOwner({
  ownerAddress: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
  page: 1,
  limit: 50,
});

// Get transaction history (with token account activity)
const txs = await helius.getTransactionsForAddress([
  "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
  { limit: 100, transactionDetails: "full", filters: { tokenAccounts: "balanceChanged" } },
]);

// Send a transaction via Helius Sender (ultra-low latency)
const sig = await helius.tx.sendTransactionWithSender({
  instructions: [transferInstruction],
  signers: [walletSigner],
  region: "US_EAST",
});
```

## Opsi Klien

```typescript theme={"system"}
const helius = createHelius({
  apiKey: "YOUR_API_KEY",       // Required for webhooks, enhanced txs, wallet API
  network: "mainnet",           // "mainnet" (default) or "devnet"
  baseUrl: "https://custom..",  // Override RPC URL (optional)
  rebateAddress: "wallet",      // Wallet for RPC rebates (optional)
  userAgent: "my-agent/1.0",   // Sent as X-Helius-Client header (optional)
});
```

## Namespace

Semua metode diakses melalui klien `helius`. Metode DAS API dan metode RPC Solana standar tersedia langsung di `helius.*`. Fungsionalitas lainnya diatur ke dalam namespace:

| Namespace      | Akses                                                                 | Tujuan                                                      |
| -------------- | --------------------------------------------------------------------- | ----------------------------------------------------------- |
| DAS API        | `helius.getAsset()`, `helius.getAssetsByOwner()`, dll.                | Mengueri NFT, token, dan aset terkompresi                   |
| RPC V2         | `helius.getTransactionsForAddress()`, `helius.getProgramAccountsV2()` | RPC yang disempurnakan dengan paginasi dan filter           |
| Transaksi      | `helius.tx.*`                                                         | Transaksi pintar dan Helius Sender                          |
| Ditingkatkan   | `helius.enhanced.*`                                                   | Mengurai transaksi menjadi format yang dapat dibaca manusia |
| Webhook        | `helius.webhooks.*`                                                   | Membuat dan mengelola langganan webhook                     |
| WebSocket      | `helius.ws.*`                                                         | Aliran data blockchain secara real-time                     |
| Staking        | `helius.stake.*`                                                      | Melakukan staking SOL ke validator Helius                   |
| ZK Compression | `helius.zk.*`                                                         | Akun dan bukti terkompresi                                  |
| Wallet API     | `helius.wallet.*`                                                     | Saldo, riwayat, dan pencarian identitas                     |
| RPC Standar    | `helius.getBalance()`, `helius.getSlot()`, dll.                       | Semua metode RPC Solana standar melalui proksi              |
| RPC Mentah     | `helius.raw`                                                          | Akses langsung ke klien Rpc `@solana/kit` yang mendasarinya |
| Autentikasi    | `import { makeAuthClient } from "helius-sdk/auth/client"`             | Pendaftaran agen dan pengelolaan kunci API (impor mandiri)  |

## Pendaftaran Terprogram (Modul Autentikasi)

Modul autentikasi merupakan impor mandiri — modul ini tidak tersedia di `HeliusClient` utama. Gunakan modul ini untuk alur pendaftaran agen secara terprogram.

```typescript theme={"system"}
import { makeAuthClient } from "helius-sdk/auth/client";

const auth = makeAuthClient();

// Hosted-link signup (returns a paymentUrl the user opens in a browser):
const link = await auth.signup({
  secretKey: keypair.secretKey,
  plan: "agent",
  email: "you@example.com",
  firstName: "Ada",
  lastName: "Lovelace",
});
// link: { kind: "payment_required", jwt, refId, walletAddress, paymentLink: { paymentUrl, ... } }

// Or pay USDC directly from the local keypair and provision in one call:
const result = await auth.signupAndPay({
  secretKey: keypair.secretKey,
  plan: "agent",
  email: "you@example.com",
  firstName: "Ada",
  lastName: "Lovelace",
});
// result.kind: "completed" | "pending" | "expired" | "failed" | "already_subscribed" | "upgrade_required"
// On "completed": result has { jwt, walletAddress, projectId, apiKey, endpoints, txSignature }
```

## Pembahasan Mendalam

<CardGroup cols={2}>
  <Card title="Best Practices" icon="lightbulb" href="/docs/id/agents/typescript-sdk/best-practices">
    Pola yang direkomendasikan, paginasi, kesalahan umum, dan penanganan kesalahan
  </Card>

  <Card title="API Reference" icon="book" href="/docs/id/agents/typescript-sdk/api-reference">
    Daftar lengkap metode untuk setiap namespace
  </Card>
</CardGroup>

## Sumber Daya

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/helius-labs/helius-sdk">
    Kode sumber, contoh, dan pelacakan masalah
  </Card>

  <Card title="Code Examples" icon="code" href="https://github.com/helius-labs/helius-sdk/tree/main/examples">
    Contoh yang dapat dijalankan untuk setiap metode, diatur berdasarkan namespace
  </Card>

  <Card title="SDK API Docs (TypeDoc)" icon="book" href="https://helius-labs.github.io/helius-sdk/">
    Dokumentasi API lengkap yang dihasilkan dari kode sumber
  </Card>

  <Card title="Migration Guide (1.x to 2.x)" icon="arrow-right" href="https://github.com/helius-labs/helius-sdk/blob/main/MIGRATION.md">
    Tingkatkan dari @solana/web3.js ke @solana/kit
  </Card>
</CardGroup>
