> ## 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 confidential dApp with create-inco-app

`create-inco-app` is the fastest way to start building on Inco. It scaffolds a confidential project — a **monorepo** with Solidity contracts and a Next.js frontend, or just the **contracts**, or just the **frontend** — pre-wired with the Inco SDK, your contract framework, and a wallet provider.

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

You'll be prompted for:

```
What is your project named?            my-app
What would you like to scaffold?       Full monorepo / Contracts only / Frontend only
Which chain would you like to use?     EVM / SVM
Which contract framework?              Hardhat / Foundry      (skipped for frontend-only)
Which wallet provider?                 RainbowKit / Privy / Dynamic / Reown / Para  (skipped for contracts-only)
```

## Scaffold modes

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

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

    <CodeGroup>
      ```bash npm theme={null}
      npx create-inco-app@latest my-app --chain evm --framework hardhat --wallet rainbowkit --yes
      ```

      ```bash pnpm theme={null}
      pnpm create inco-app@latest my-app --chain evm --framework hardhat --wallet rainbowkit --yes
      ```

      ```bash yarn theme={null}
      yarn create inco-app my-app --chain evm --framework hardhat --wallet rainbowkit --yes
      ```

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

    ```
    my-app/
    ├── contracts/        # Solidity (Hardhat or Foundry) — ConfidentialERC20 + ConfidentialLottery
    ├── frontend/         # Next.js app (wallet provider + Inco SDK wired up)
    └── package.json      # workspace root (npm run dev, contracts:compile, ...)
    ```
  </Tab>

  <Tab title="Contracts only">
    Just the contract project — Hardhat or Foundry — no frontend.

    <CodeGroup>
      ```bash Foundry theme={null}
      npx create-inco-app@latest my-contracts --template contracts --chain evm --framework foundry --yes
      ```

      ```bash Hardhat theme={null}
      npx create-inco-app@latest my-contracts --template contracts --chain evm --framework hardhat --yes
      ```
    </CodeGroup>

    ```
    # Foundry                          # Hardhat
    my-contracts/                      my-contracts/
    ├── src/                           ├── contracts/      # Solidity files
    ├── test/                          ├── test/
    ├── script/                        ├── ignition/       # deployment modules
    ├── foundry.toml                   ├── hardhat.config.ts
    ├── remappings.txt                 ├── utils/
    └── docker-compose.yaml            └── docker-compose.yaml
    ```
  </Tab>

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

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

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

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

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

    ```
    my-frontend/
    ├── app/              # Next.js App Router
    ├── components/       # Providers.tsx (wallet) + UI
    ├── hooks/            # Inco SDK integration
    ├── lib/network.ts    # network + Inco Lightning factory
    └── abi/
    ```
  </Tab>
</Tabs>

## Reference

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

| Option                                                  | Description                                                        |
| ------------------------------------------------------- | ------------------------------------------------------------------ |
| `-t`, `--template <type>`                               | Scaffold type: `monorepo` (default), `contracts`, `frontend`       |
| `-c`, `--chain <chain>`                                 | Chain type: `evm`, `svm`                                           |
| `-f`, `--framework <fw>`                                | Contract framework: `hardhat`, `foundry` (EVM), `anchor` (SVM)     |
| `-w`, `--wallet <provider>`                             | Wallet provider: `rainbowkit`, `privy`, `dynamic`, `reown`, `para` |
| `-y`, `--yes`                                           | Skip prompts, use defaults                                         |
| `--git`                                                 | Initialize a git repository                                        |
| `--install`                                             | Install dependencies after scaffolding                             |
| `--use-npm` / `--use-pnpm` / `--use-yarn` / `--use-bun` | Choose the package manager                                         |
| `-h`, `--help`                                          | Show all options                                                   |
| `-v`, `--version`                                       | Print the version                                                  |

## Networks

The project targets **Base Sepolia by default** and supports **Base Mainnet**. The frontend selects the network from a single env var — no code changes needed:

```bash frontend/.env theme={null}
# "testnet" (Base Sepolia, default) or "mainnet" (Base Mainnet)
NEXT_PUBLIC_NETWORK=testnet
```

`lib/network.ts` reads it and returns the matching Inco Lightning client (`Lightning.baseSepoliaTestnet()` or `Lightning.baseMainnet()`).

## After setup (monorepo)

1. Install dependencies:

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

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

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

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

2. Set up frontend env vars:

   ```bash theme={null}
   cp frontend/.env.example frontend/.env
   # set NEXT_PUBLIC_NETWORK, your wallet key(s), and NEXT_PUBLIC_CONFLOTTERY_ADDRESS after deploy
   ```

3. Compile and test the contracts:

   <CodeGroup>
     ```bash npm theme={null}
     npm run contracts:compile
     npm run contracts:test
     ```

     ```bash pnpm theme={null}
     pnpm contracts:compile
     pnpm contracts:test
     ```

     ```bash yarn theme={null}
     yarn contracts:compile
     yarn contracts:test
     ```

     ```bash bun theme={null}
     bun run contracts:compile
     bun run contracts:test
     ```
   </CodeGroup>

4. (Optional) Deploy — copy `contracts/.env.sample` to `contracts/.env` and fill in the key for your target network, then:

   ```bash theme={null}
   # local Inco node (anvil + covalidator) — run in a separate terminal
   npm run contracts:node
   # deploy
   npm run contracts:deploy:local      # or :deploy:testnet / :deploy:mainnet
   ```

   `contracts/.env` keys, per target network:

   ```bash contracts/.env theme={null}
   PRIVATE_KEY_ANVIL=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80  # local default
   PRIVATE_KEY_BASE_SEPOLIA=<your-testnet-key>
   PRIVATE_KEY_BASE=<your-mainnet-key>
   ```

5. Start the frontend (set `NEXT_PUBLIC_CONFLOTTERY_ADDRESS` to your deployed address first):

   <CodeGroup>
     ```bash npm theme={null}
     npm run dev
     ```

     ```bash pnpm theme={null}
     pnpm dev
     ```

     ```bash yarn theme={null}
     yarn dev
     ```

     ```bash bun theme={null}
     bun run dev
     ```
   </CodeGroup>

   Open [http://localhost:3000](http://localhost:3000).

## Workspace scripts (monorepo)

| Script                             | Description                                     |
| ---------------------------------- | ----------------------------------------------- |
| `npm run dev`                      | Start the frontend dev server                   |
| `npm run build`                    | Build the frontend                              |
| `npm run contracts:compile`        | Compile the contracts                           |
| `npm run contracts:test`           | Run the contract tests                          |
| `npm run contracts:node`           | Start the local Inco node (anvil + covalidator) |
| `npm run contracts:deploy:local`   | Deploy the lottery to the local node            |
| `npm run contracts:deploy:testnet` | Deploy the lottery to Base Sepolia              |
| `npm run contracts:deploy:mainnet` | Deploy the lottery to Base Mainnet              |

<Note>
  `deploy:token:local` / `:testnet` / `:mainnet` variants deploy only the `ConfidentialERC20` token. Each deploy reads its key from `contracts/.env` by target chain (`PRIVATE_KEY_ANVIL` / `PRIVATE_KEY_BASE_SEPOLIA` / `PRIVATE_KEY_BASE`).
</Note>

## Inco SDK integration

The frontend talks to Inco through `@inco/lightning-js`. The network-aware client comes from `lib/network.ts`:

```ts lib/network.ts theme={null}
import { Lightning } from "@inco/lightning-js/lite";

// NEXT_PUBLIC_NETWORK: "testnet" (Base Sepolia, default) or "mainnet" (Base Mainnet)
export async function getIncoLightning() {
  return process.env.NEXT_PUBLIC_NETWORK === "mainnet"
    ? Lightning.baseMainnet()
    : Lightning.baseSepoliaTestnet();
}
```

Encrypt a value before sending it on-chain, then decrypt results with attestation:

```ts theme={null}
import { getIncoLightning } from "@/lib/network";
import { handleTypes } from "@inco/lightning-js";
import { parseEther } from "viem";

const zap = await getIncoLightning();

// Encrypt an amount for the contract
const ciphertext = await zap.encrypt(parseEther(amount), {
  accountAddress: address,
  dappAddress: contractAddress,
  handleType: handleTypes.euint256,
});

// The Inco executor fee is read from the network and passed as msg.value
const fee = await publicClient.readContract({
  address: zap.executorAddress,
  abi: getFeeAbi,
  functionName: "getFee",
});

writeContract({ address: contractAddress, abi, functionName: "encryptedMint", args: [ciphertext], value: fee });

// Decrypt a handle with attestation (e.g. check if the user won)
const [result] = await zap.attestedDecrypt(walletClient, [encryptedHandle]);
const plaintext = result.plaintext.value;
```

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

## Choose your wallet provider

Each provider has its own setup. Select one to see the provider configuration and how it integrates with Inco:

<CardGroup cols={3}>
  <Card title="RainbowKit" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/rainbowkit.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=7d6848666fd338cb33b0b81366ff9db8" href="/quickstart/wallets/rainbowkit" width="120" height="120" data-path="wallets/rainbowkit.svg">
    Multi-wallet connector (recommended)
  </Card>

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

  <Card title="Dynamic" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/dynamic.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=f3a87589c1ddff2bdf43617a951ad9e5" href="/quickstart/wallets/dynamic" width="120" height="120" data-path="wallets/dynamic.svg">
    Multi-chain wallet orchestration
  </Card>

  <Card title="Reown" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/reown.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=f066cbeb8bbff131f9f6e050ce3cd527" href="/quickstart/wallets/reown" width="120" height="120" data-path="wallets/reown.svg">
    WalletConnect-powered connections
  </Card>

  <Card title="Para" img="https://mintcdn.com/inco/ATAF7MZMLS3SasjU/wallets/para.svg?fit=max&auto=format&n=ATAF7MZMLS3SasjU&q=85&s=d2cbd9331eacaecc84777b24c04bf1c0" href="/quickstart/wallets/para" width="120" height="120" data-path="wallets/para.svg">
    Embedded + external wallet support
  </Card>
</CardGroup>
