> ## 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={2}>
  <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>

  <Card title="Attested Compute" icon="calculator" href="/svm/js-sdk/attestations/attested-compute">
    Off-chain comparisons with attestation
  </Card>

  <Card title="Allowance Voucher" icon="key" href="/svm/js-sdk/voucher/allowance-voucher">
    Session keys for delegated decrypt/compute
  </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 Decrypt vs Compute

| Feature                | Attested Reveal         | Attested Decrypt                          | Attested Compute                               |
| ---------------------- | ----------------------- | ----------------------------------------- | ---------------------------------------------- |
| **Purpose**            | Display values in UI    | Verify plaintext on-chain                 | Off-chain comparison + optional on-chain proof |
| **What you use**       | `result.plaintexts`     | `result.ed25519Instructions` + program IX | `result.result` + `result.ed25519Instruction`  |
| **Reveals raw value?** | Yes                     | Yes                                       | No (only `"0"` / `"1"`)                        |
| **On-chain TX**        | No                      | Yes                                       | Optional                                       |
| **Use case**           | Show user their balance | Conditional logic on plaintext            | `score >= 700` without revealing score         |

```typescript theme={null}
import { decrypt } from '@inco/solana-sdk/attested-decrypt';
import {
  attestedCompute,
  AttestedComputeSupportedOps,
} from '@inco/solana-sdk/attested-compute';

const result = await decrypt([handle], {
  address: wallet.publicKey,
  signMessage: wallet.signMessage,
});

// 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);

// Attested Compute: compare without revealing the raw value
const cmp = await attestedCompute(
  { lhsHandle: handle, op: AttestedComputeSupportedOps.Ge, rhsPlaintext: 700n },
  { address: wallet.publicKey, signMessage: wallet.signMessage }
);
console.log(cmp.result); // "1" or "0"
```
