> For the complete documentation index, see [llms.txt](https://docs.keystonefi.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keystonefi.xyz/build-on-it/quick-start.md).

# Quick Start

Read the vault's state and call it from your own code.

The vault is a singleton, deployed and initialized by the Keystone admin. You don't stand one up yourself — you point a client at the existing program and read or transact against it.

***

## Prerequisites

Only Node.js 20+ is needed to build against the vault. The Rust and Anchor toolchain below is for compiling the program from source, which you only need if you're reviewing or modifying it.

| Tool       | Version                | Needed for                 |
| ---------- | ---------------------- | -------------------------- |
| Node.js    | 20+                    | Client integration         |
| Rust       | 1.79+ (rustup-managed) | Building the program       |
| Anchor CLI | 0.32.1+                | Building the program / IDL |
| Solana CLI | 1.18+                  | Building the program       |

```bash
git clone https://github.com/kamwithak/keystone-contracts.git
cd keystone-contracts
npm install
```

***

## Program ID

| Network | Program ID                                     |
| ------- | ---------------------------------------------- |
| Devnet  | `E7tpCcxtvuTXLAckBGWb1AsndpLQ1Y9hQA3iGYSXz2vJ` |
| Mainnet | *pending audit*                                |

* Single Anchor program: `keystone_finance`
* Implements the ksUSD vault end-to-end
* 27 instructions · 42 errors · 25 events · 2 account types

***

## Build

```bash
# Rust check (fast, no BPF toolchain required)
cargo check -p keystone-finance

# Generate / refresh IDL from source (uses idl-build feature)
PATH="$HOME/.cargo/bin:$PATH" anchor idl build \
  -o target/idl/keystone_finance.json
```

* IDL: the generated IDL — regenerated to match latest source
* TS types: the generated TypeScript types — derived from the IDL

***

## What you can call

Anyone can call these, and they're the whole surface most integrations need:

| Instruction                                           | Does                                               |
| ----------------------------------------------------- | -------------------------------------------------- |
| `deposit(usdc_amount)`                                | USDC in, ksUSD out at the current share price      |
| `withdraw_instant(shares)`                            | ksUSD in, USDC out of the liquidity buffer         |
| `request_withdrawal(shares)` + `process_withdrawal()` | Queued path for withdrawals larger than the buffer |

Position management (`open_position`, `close_position`, `attest_nav`, the lending cranks) is gated to the vault's authorized keeper. `settle`, `process_withdrawal`, and `emergency_close` need no permission at all. Full list in the [instructions reference](/build-on-it/quick-start/instructions.md).

***

## TypeScript client

```ts
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { Connection, PublicKey } from "@solana/web3.js";
import idl from "../target/idl/keystone_finance.json" with { type: "json" };

const PROGRAM_ID = new PublicKey("E7tpCcxtvuTXLAckBGWb1AsndpLQ1Y9hQA3iGYSXz2vJ");
const connection = new Connection("https://api.devnet.solana.com", "confirmed");

const provider = new anchor.AnchorProvider(connection, wallet, { commitment: "confirmed" });
anchor.setProvider(provider);

const program = new Program(idl as any, provider);

const [vaultPda] = PublicKey.findProgramAddressSync(
  [Buffer.from("vault")],
  PROGRAM_ID
);

const vault = await program.account.vault.fetch(vaultPda);
```

***

## Related

* [Instructions reference](/build-on-it/quick-start/instructions.md) — every entry point
* [Account structure](/build-on-it/quick-start/accounts.md) — `Vault` and `WithdrawalRequest` layouts
* [Events](/build-on-it/quick-start/events.md) · [Errors](/build-on-it/quick-start/errors.md)
* [Deposit](/start-here/deposit.md) · [Withdraw](/start-here/withdraw.md) · [Check position & NAV](/start-here/check-position.md)
