npm package: @hyr0-xyz/react
Description: TypeScript SDK for building dApps on Hyro Protocol. This SDK provides high-level APIs for interacting with Hyro Protocol's Vault and Transaction systems.
Latest version: 0.0.4

# @hyr0-xyz/program

TypeScript SDK for building dApps on Hyro Protocol. This SDK provides high-level APIs for interacting with Hyro Protocol's Vault and Transaction systems.

## Installation

```bash
npm install @hyr0-xyz/program @solana/kit
# or
yarn add @hyr0-xyz/program @solana/kit
# or
pnpm add @hyr0-xyz/program @solana/kit
```

## Features

- **Vault Operations**: Create, fetch, and manage vaults
- **Transaction Operations**: Create and execute transactions through vaults
- **PDA Helpers**: Easy-to-use functions for deriving Program Derived Addresses
- **Type-Safe**: Full TypeScript support with type-safe APIs
- **Built on @solana/kit**: Uses the latest Solana TypeScript toolkit

## Quick Start

### Vault Operations

```typescript
import { VaultSDK } from '@hyr0-xyz/program';
import { createSolanaRpc } from '@solana/kit';

// Get RPC connection
const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');

// Get vault PDA from seed
const [vaultPda, authorityPda] = await VaultSDK.getVaultPda('my-vault-seed');

// Fetch vault data
const vault = await VaultSDK.fetch(rpc, vaultPda[0]);
console.log('Vault data:', vault.data);

// Get related PDAs
const shareSignerPda = await VaultSDK.getShareSignerPda(vaultPda);
const shareMintPda = await VaultSDK.getShareMintPda(vaultPda);
```

### Transaction Operations

```typescript
import { TransactionSDK } from '@hyr0-xyz/program';

// Get transaction PDA
const transactionPda = await TransactionSDK.getTransactionPda(vaultPda, 1);

// Fetch transaction data
const transaction = await TransactionSDK.fetch(rpc, transactionPda[0]);
console.log('Transaction data:', transaction.data);

// Build create transaction instruction
const createTxIx = await TransactionSDK.buildCreateTxInstruction({
  vault: vaultPda[0],
  nonce: 1,
  programId: 'YourProgramId...',
  accounts: [
    {
      pubkey: 'AccountAddress...',
      isSigner: false,
      isWritable: true,
    },
  ],
  data: new Uint8Array([...]),
  policyAccount: 'PolicyAccount...',
  policyProgram: 'PolicyProgram...',
  signer: yourSigner,
});

// Build execute transaction instruction
const executeTxIx = await TransactionSDK.buildExecuteTxInstruction({
  vault: vaultPda[0],
  transaction: transactionPda[0],
  policyAccount: 'PolicyAccount...',
  policyProgram: 'PolicyProgram...',
  signer: yourSigner,
});
```

### PDA Helpers

```typescript
import { getVaultPda, getTransactionPda, getShareSignerPda } from '@hyr0-xyz/program';

// Get vault and authority PDAs
const [vault, authority] = await getVaultPda('my-seed');

// Get transaction PDA
const txPda = await getTransactionPda(vault, 1);

// Get share signer PDA
const shareSigner = await getShareSignerPda(vault);
```

## API Reference

### VaultSDK

#### `getVaultPda(seed: string)`
Get vault PDA and authority PDA from a seed string.

#### `fetch(rpc, address)`
Fetch vault account data from the blockchain.

#### `getShareSignerPda(vault)`
Get the share signer PDA for a vault.

#### `getShareMintPda(vault)`
Get the share mint PDA for a vault.

#### `getVaultTokenAccountPda(vault, underlyingMint)`
Get the vault token account PDA.

#### `buildInitializeVaultInstruction(params)`
Build an instruction to initialize a new vault.

### TransactionSDK

#### `getTransactionPda(vault, nonce)`
Get transaction PDA from vault and nonce.

#### `fetch(rpc, address)`
Fetch transaction account data from the blockchain.

#### `buildCreateTxInstruction(params)`
Build an instruction to create a new transaction.

#### `buildExecuteTxInstruction(params)`
Build an instruction to execute a transaction.

## Development

```bash
# Install dependencies
npm install

# Build
npm run build

# Type check
npm run typecheck
```

## License

ISC