open-index/open-npm huggingface dataset:
npm package: @inco/solana-sdk
Description: TypeScript SDK for Inco Solana
Latest version: 0.0.2

# @inco/solana-sdk

TypeScript SDK for building confidential applications on Solana using Inco's Trusted Execution Environment (TEE).

## Installation

```bash
npm install @inco/solana-sdk
```

## Features

- **Encryption** - Encrypt values for TEE-compatible on-chain storage
- **Attested Decryption** - Decrypt encrypted handles with Ed25519 signature verification

## Quick Start

### Encryption

```typescript
import { encryptValue } from '@inco/solana-sdk/encryption';

const encryptedHex = await encryptValue(1000n);
```

### Attested Decryption

```typescript
import { decrypt } from '@inco/solana-sdk/attested-decrypt';

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

console.log(result.plaintexts);        // Decrypted values
console.log(result.signatures);        // Raw signatures from covalidator
console.log(result.ed25519Instructions); // Ed25519 instructions for on-chain verification
```

## API Reference

### `encryptValue(value): Promise<string>`

Encrypts a value and returns hex string.

**Parameters:**
- `value` - `bigint | number | boolean`

**Returns:** Hex-encoded encrypted data

### `decrypt(handles, options): Promise<AttestedDecryptResult>`

Decrypts handles and returns plaintexts with Ed25519 instructions.

**Parameters:**
- `handles` - `string[]` (max 10)
- `options` - `DecryptOptions`
  - `address` - Wallet public key (base58 string or PublicKey)
  - `signMessage` - Function to sign a message with the wallet

**Returns:**
```typescript
{
  plaintexts: string[];                 // Decrypted values
  handles: string[];                    // Original handles
  ed25519Instructions: TransactionInstruction[];  // For on-chain verification
  signatures: string[];                 // Raw signatures (base58)
}
```

## Example: On-chain Attestation

```typescript
import { decrypt } from '@inco/solana-sdk/attested-decrypt';
import { Transaction } from '@solana/web3.js';

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

// Build transaction with Ed25519 verification
const tx = new Transaction();
result.ed25519Instructions.forEach(ix => tx.add(ix));
tx.add(yourProgramInstruction);

// Send transaction
await wallet.sendTransaction(tx, connection);
```