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

# JavaScript SDK Overview

> Client-side SDK for interacting with confidential Solana programs

# JavaScript SDK

The Inco JavaScript SDK provides client-side utilities for building privacy-preserving applications on Solana. It handles encryption and decryption workflows.

## Installation

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

  ```bash yarn theme={null}
  yarn add @inco/solana-sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @inco/solana-sdk
  ```
</CodeGroup>

## Features

<CardGroup cols={3}>
  <Card title="Encryption" icon="lock" href="/svm/js-sdk/encryption">
    Encrypt values client-side for Inco operations
  </Card>

  <Card title="Attested Reveal" icon="eye" href="/svm/js-sdk/attestations/attested-reveal">
    Decrypt handles for off-chain display
  </Card>

  <Card title="Attested Decrypt" icon="shield-check" href="/svm/js-sdk/attestations/attested-decrypt">
    Decrypt with on-chain verification
  </Card>
</CardGroup>

## Quick Start

```typescript theme={null}
import { encryptValue } from '@inco/solana-sdk/encryption';
import { decrypt } from '@inco/solana-sdk/attested-decrypt';
import { hexToBuffer } from '@inco/solana-sdk/utils';

// 1. Encrypt a value before sending to your program
const encrypted = await encryptValue(1000n);

// 2. Use in your program instruction
await program.methods
  .someOperation(hexToBuffer(encrypted), 0)
  .accounts({ authority: wallet.publicKey })
  .rpc();

// 3. Decrypt the result handle (requires wallet signature)
const result = await decrypt([handle], {
  address: wallet.publicKey,
  signMessage: wallet.signMessage,
});
console.log(result.plaintexts[0]);  // Decrypted value
```

## Supported Value Types

| Type      | Example         | Notes                     |
| --------- | --------------- | ------------------------- |
| `number`  | `42`, `100`     | Integers only (no floats) |
| `bigint`  | `1000000000n`   | For large values          |
| `boolean` | `true`, `false` | Encrypted as 0 or 1       |

## Attested Reveal vs Attested Decrypt

Both use the same `decrypt()` function. The difference is how you use the result:

| Feature          | Attested Reveal         | Attested Decrypt                            |
| ---------------- | ----------------------- | ------------------------------------------- |
| **Purpose**      | Display values in UI    | Verify values on-chain                      |
| **What you use** | `result.plaintexts`     | `result.ed25519Instructions` + program IX   |
| **On-chain TX**  | No                      | Yes                                         |
| **Use case**     | Show user their balance | Conditional logic based on decrypted values |

```typescript theme={null}
const result = await decrypt([handle]);

// Attested Reveal: Just read the plaintext
console.log(result.plaintexts[0]);

// Attested Decrypt: Build on-chain verification transaction
const tx = new Transaction();
result.ed25519Instructions.forEach(ix => tx.add(ix));
tx.add(yourProgramInstruction);
```
