> ## 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.

# Build a dApp

> Scaffold a full-stack confidential Solana dApp with create-inco-app

The `create-inco-app` CLI allows you to create a new full-stack confidential dApp with a Next.js frontend, Anchor programs (Rust), and the Inco Solana SDK. It is the easiest way to get started building on Inco for Solana.

## Basic usage

<CodeGroup>
  ```bash npm theme={null}
  npx create-inco-app@latest
  ```

  ```bash pnpm theme={null}
  pnpm create inco-app@latest
  ```

  ```bash yarn theme={null}
  yarn create inco-app
  ```

  ```bash bun theme={null}
  bunx create-inco-app@latest
  ```
</CodeGroup>

On installation, you'll see the following prompts:

```
What is your project named?            my-app
What would you like to scaffold?       Full monorepo / Programs only / Frontend only
Which chain would you like to use?     SVM
Which contract framework?              Anchor                          (skipped for frontend-only)
Which wallet provider?                 Solana Wallet Adapter / Privy   (skipped for programs-only)
```

After the prompts, `create-inco-app` will create a folder with your project name and install the required dependencies.

## Scaffold modes

Choose what to generate with `--template` (or the second prompt). Programs-only and frontend-only are scaffolded **at the project root** (no monorepo wrapper).

<Tabs>
  <Tab title="Full monorepo (default)">
    Anchor programs **and** frontend in one workspace.

    <CodeGroup>
      ```bash npm theme={null}
      npx create-inco-app@latest my-app --chain svm --framework anchor --wallet privy --yes
      ```

      ```bash pnpm theme={null}
      pnpm create inco-app@latest my-app --chain svm --framework anchor --wallet privy --yes
      ```

      ```bash yarn theme={null}
      yarn create inco-app my-app --chain svm --framework anchor --wallet privy --yes
      ```

      ```bash bun theme={null}
      bunx create-inco-app@latest my-app --chain svm --framework anchor --wallet privy --yes
      ```
    </CodeGroup>

    ```
    my-app/
    ├── programs/         # Anchor workspace — confidential-pool + confidential-token
    ├── frontend/         # Next.js app (wallet provider + Inco Solana SDK wired up)
    ├── scripts/          # sync-programs.mjs (syncs IDLs + program IDs after deploy)
    └── package.json      # workspace root (npm run dev, programs:build, ...)
    ```
  </Tab>

  <Tab title="Programs only">
    Just the Anchor workspace — no frontend.

    <CodeGroup>
      ```bash npm theme={null}
      npx create-inco-app@latest my-programs --template contracts --chain svm --framework anchor --yes
      ```

      ```bash pnpm theme={null}
      pnpm create inco-app@latest my-programs --template contracts --chain svm --framework anchor --yes
      ```

      ```bash yarn theme={null}
      yarn create inco-app my-programs --template contracts --chain svm --framework anchor --yes
      ```

      ```bash bun theme={null}
      bunx create-inco-app@latest my-programs --template contracts --chain svm --framework anchor --yes
      ```
    </CodeGroup>

    ```
    my-programs/
    ├── programs/         # Rust programs
    ├── tests/
    ├── Anchor.toml
    └── Cargo.toml
    ```

    Scripts: `anchor build` (`build`), `anchor test` (`test`), `anchor deploy` (`deploy`).
  </Tab>

  <Tab title="Frontend only">
    Just the Next.js dApp — no programs. Wire it to an already-deployed program.

    <CodeGroup>
      ```bash npm theme={null}
      npx create-inco-app@latest my-frontend --template frontend --chain svm --wallet privy --yes
      ```

      ```bash pnpm theme={null}
      pnpm create inco-app@latest my-frontend --template frontend --chain svm --wallet privy --yes
      ```

      ```bash yarn theme={null}
      yarn create inco-app my-frontend --template frontend --chain svm --wallet privy --yes
      ```

      ```bash bun theme={null}
      bunx create-inco-app@latest my-frontend --template frontend --chain svm --wallet privy --yes
      ```
    </CodeGroup>

    ```
    my-frontend/
    ├── app/              # Next.js App Router
    ├── components/       # Providers.tsx (wallet) + UI
    ├── hooks/            # Inco Solana SDK integration
    ├── idl/              # program IDLs
    └── lib/
    ```
  </Tab>
</Tabs>

## Reference

```
npx create-inco-app@latest [project-name] [options]
```

The following options are available:

| Option                        | Description                                         |
| ----------------------------- | --------------------------------------------------- |
| `-h` or `--help`              | Show all available options                          |
| `-v` or `--version`           | Output the version number                           |
| `-t` or `--template <value>`  | Scaffold type (`monorepo`, `contracts`, `frontend`) |
| `-f` or `--framework <value>` | Contract framework (`anchor`)                       |
| `-w` or `--wallet <value>`    | Wallet provider (`solana-wallet-adapter`, `privy`)  |
| `-c` or `--chain <value>`     | Chain type (`svm`)                                  |
| `-y` or `--yes`               | Skip prompts, use defaults                          |
| `--install`                   | Auto-install dependencies after scaffolding         |
| `--git`                       | Initialize a git repository                         |
| `--use-npm`                   | Explicitly tell the CLI to bootstrap using npm      |
| `--use-pnpm`                  | Explicitly tell the CLI to bootstrap using pnpm     |
| `--use-yarn`                  | Explicitly tell the CLI to bootstrap using Yarn     |
| `--use-bun`                   | Explicitly tell the CLI to bootstrap using Bun      |

## Project Structure

The scaffolded project is a monorepo with two workspaces:

```
my-app/
├── programs/              # Anchor workspace (Rust programs)
│   ├── programs/
│   │   ├── confidential-pool/     # Privacy-preserving lottery
│   │   └── confidential-token/    # Encrypted token system
│   ├── tests/             # Integration tests
│   └── Anchor.toml        # Anchor configuration (devnet)
└── frontend/              # Next.js app (pre-configured for Solana devnet)
    ├── components/
    │   ├── Providers.tsx       # Wallet provider setup
    │   └── ConfPool.tsx        # Example dApp component
    ├── hooks/
    │   └── useConfPool.ts      # Inco Solana SDK integration
    └── idl/                    # Program IDLs (auto-synced)
```

<Note>
  The frontend is pre-configured for **Solana devnet**. All wallet providers connect to devnet by default, no network configuration changes are needed.
</Note>

## Examples

### With default options

<CodeGroup>
  ```bash npm theme={null}
  npx create-inco-app@latest
  ```

  ```bash pnpm theme={null}
  pnpm create inco-app@latest
  ```

  ```bash yarn theme={null}
  yarn create inco-app
  ```

  ```bash bun theme={null}
  bunx create-inco-app@latest
  ```
</CodeGroup>

### With Anchor and Solana Wallet Adapter

<CodeGroup>
  ```bash npm theme={null}
  npx create-inco-app@latest my-app --framework anchor --wallet solana-wallet-adapter --chain svm --yes
  ```

  ```bash pnpm theme={null}
  pnpm create inco-app@latest my-app --framework anchor --wallet solana-wallet-adapter --chain svm --yes
  ```

  ```bash yarn theme={null}
  yarn create inco-app my-app --framework anchor --wallet solana-wallet-adapter --chain svm --yes
  ```

  ```bash bun theme={null}
  bunx create-inco-app@latest my-app --framework anchor --wallet solana-wallet-adapter --chain svm --yes
  ```
</CodeGroup>

### With Anchor and Privy

<CodeGroup>
  ```bash npm theme={null}
  npx create-inco-app@latest my-app --framework anchor --wallet privy --chain svm --yes
  ```

  ```bash pnpm theme={null}
  pnpm create inco-app@latest my-app --framework anchor --wallet privy --chain svm --yes
  ```

  ```bash yarn theme={null}
  yarn create inco-app my-app --framework anchor --wallet privy --chain svm --yes
  ```

  ```bash bun theme={null}
  bunx create-inco-app@latest my-app --framework anchor --wallet privy --chain svm --yes
  ```
</CodeGroup>

## Build & Test Programs

Run the test command from the project root — it builds, deploys to a local validator, runs tests, and automatically syncs the program IDs and IDLs to the frontend:

<CodeGroup>
  ```bash npm theme={null}
  cd my-app
  npm install
  npm run programs:test
  ```

  ```bash pnpm theme={null}
  cd my-app
  pnpm install
  pnpm run programs:test
  ```

  ```bash yarn theme={null}
  cd my-app
  yarn install
  yarn programs:test
  ```

  ```bash bun theme={null}
  cd my-app
  bun install
  bun run programs:test
  ```
</CodeGroup>

After the test completes, the frontend `.env` is automatically updated with the deployed program IDs.

Then run the frontend:

<CodeGroup>
  ```bash npm theme={null}
  cd my-app && npm run dev
  ```

  ```bash pnpm theme={null}
  cd my-app && pnpm run dev
  ```

  ```bash yarn theme={null}
  cd my-app && yarn dev
  ```

  ```bash bun theme={null}
  cd my-app && bun run dev
  ```
</CodeGroup>

Open [http://localhost:3000](http://localhost:3000) to see your dApp.

<Note>
  For **Privy**, you need a Privy App ID with Solana (SVM) enabled. Set `NEXT_PUBLIC_PRIVY_APP_ID` in `frontend/.env.local` before running the frontend. For **Solana Wallet Adapter**, no additional configuration is needed — it works out of the box.
</Note>

## Inco Solana SDK Integration

The scaffolded app uses `@inco/solana-sdk` for client-side encryption. On-chain, the Anchor programs use `inco-lightning` CPI for encrypted operations.

### Client-side encryption

```tsx theme={null}
import { encryptValue } from "@inco/solana-sdk/encryption";
import { hexToBuffer } from "@inco/solana-sdk/utils";

// Encrypt a value before sending on-chain
const amount = BigInt(Math.floor(parseFloat("100") * 1e9));
const encryptedHex = await encryptValue(amount);

// Pass encrypted value to your Anchor program
const tx = await program.methods
  .mintTo(hexToBuffer(encryptedHex), 0)
  .accounts({
    mint: mintAddress,
    account: tokenAccountAddress,
    mintAuthority: publicKey,
    incoLightningProgram: INCO_LIGHTNING_PROGRAM_ID,
    systemProgram: SystemProgram.programId,
  })
  .transaction();
```

### On-chain encrypted operations (Rust)

```rust theme={null}
use inco_lightning::instructions::*;

// Encrypted addition
e_add(ctx, pool.pool_balance, participant.deposit_amount)?;

// Encrypted comparison
e_eq(ctx, participant.index_handle, pool.winner_index)?;

// Random encrypted value
e_rand(ctx)?;

// Grant decryption access
allow(ctx, handle, allowed_address)?;
```

See [Encryption](/svm/js-sdk/encryption) and [Attested Decrypt](/svm/js-sdk/attestations/attested-decrypt) for full details.

## Choose Your Wallet Provider

Each wallet provider has its own setup. Select one to see the provider configuration:

<CardGroup cols={2}>
  <Card title="Solana Wallet Adapter" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/solana.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=624c256cc3506ad418fe15e9f7bd0c8f" href="/svm/quickstart/wallets/solana-wallet-adapter" width="148" height="148" data-path="wallets/solana.svg">
    Native Solana wallets (Phantom, Solflare)
  </Card>

  <Card title="Privy" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/privy.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=bfbd810a0117928825c8d7b0e7f9b3e2" href="/svm/quickstart/wallets/privy" width="120" height="120" data-path="wallets/privy.svg">
    Embedded wallets & social login
  </Card>
</CardGroup>

## Quick Reference

| Command                  | Description                                |
| ------------------------ | ------------------------------------------ |
| `npm run programs:test`  | Build, test, and sync programs to frontend |
| `npm run programs:build` | Build Anchor programs only                 |
| `npm run programs:sync`  | Sync IDLs and program IDs to frontend      |
| `npm run dev`            | Start frontend                             |
