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

# Examples

> Runnable TypeScript examples covering the whole SDK surface.

The [**cesto-sdk-examples**](https://github.com/cesto-co/cesto-sdk-examples) repository is a
small TypeScript app with one runnable script per SDK feature (via [tsx](https://tsx.is),
no build step) — clone it, add your API key, and run any example:

```bash theme={null}
git clone https://github.com/cesto-co/cesto-sdk-examples
cd cesto-sdk-examples
pnpm install
cp .env.example .env   # add your CESTO_API_KEY (and wallet vars for the write examples)

pnpm byow:products
```

Requires **Node.js 20.6+**.

The repo covers **both** integration tracks:

* **BYOW** (`byow:*`) — client-signed flows: your own Solana wallet signs every write
  (open / close / split-flow / bridges).
* **Managed** (`managed:*`) — the managed-wallets flow: `users.create` + `*.start`, with
  Cesto signing server-side — no key handling on your side. See
  [Managed Wallets](https://docs.cesto.co/sdk/managed-wallets.md).

## What's included

| Example | Run | Docs |
| - | - | - |
| BYOW: List products (+ backtests) | `pnpm byow:products` | [Products](https://docs.cesto.co/sdk/products.md) |
| BYOW: Product detail + chart | `pnpm byow:product` | [Products](https://docs.cesto.co/sdk/products.md) |
| BYOW: Positions by wallet | `pnpm byow:positions` | [Positions](https://docs.cesto.co/sdk/positions.md) |
| BYOW: Live position in one basket | `pnpm byow:position` | [Positions](https://docs.cesto.co/sdk/positions.md) |
| BYOW: Open a position (one call) | `pnpm byow:open --yes` | [Open a Position](https://docs.cesto.co/sdk/open-position.md) |
| BYOW: Close a position (one call) | `pnpm byow:close --yes` | [Close a Position](https://docs.cesto.co/sdk/close-position.md) |
| BYOW: Explicit prepare → sign → submit → poll | `pnpm byow:split-flow --yes` | [Open a Position](https://docs.cesto.co/sdk/open-position.md) |
| BYOW: Typed errors, overrides, cancellation | `pnpm byow:errors` | [Errors & Retries](https://docs.cesto.co/sdk/errors.md) |
| BYOW: Bridge USDC Base → Solana | `pnpm byow:bridge:base-to-solana --yes` | [Bridging (CCTP)](https://docs.cesto.co/sdk/bridging.md) |
| BYOW: Bridge USDC Solana → Base (withdrawal) | `pnpm byow:bridge:solana-to-base --yes` | [Bridging (CCTP)](https://docs.cesto.co/sdk/bridging.md) |
| Managed: Provision a user + wallet | `pnpm managed:user` | [Managed Wallets](https://docs.cesto.co/sdk/managed-wallets.md) |
| Managed: Fund the wallet from Base | `pnpm managed:fund --yes` | [Managed Wallets](https://docs.cesto.co/sdk/managed-wallets.md) |
| Managed: Open a position | `pnpm managed:open --yes` | [Managed Wallets](https://docs.cesto.co/sdk/managed-wallets.md) |
| Managed: Exercise every GET endpoint | `pnpm managed:gets` | [Positions](https://docs.cesto.co/sdk/positions.md) |
| Managed: Close a position | `pnpm managed:close --yes` | [Close a Position](https://docs.cesto.co/sdk/close-position.md) |
| Managed: Check wallet balances | `pnpm managed:balances` | [Managed Wallets](https://docs.cesto.co/sdk/managed-wallets.md) |

> [!WARNING]
>
> The open / close / split-flow / bridge and managed write examples move **real USDC on
> mainnet** (Solana and Base), spending from the wallets you configure (Cesto sponsors
> open/close gas). Write examples refuse to run without an explicit `--yes` flag — use
> dedicated test wallets with small amounts, and a **write-scoped** API key (see
> [Authentication](https://docs.cesto.co/sdk/authentication.md)).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.