> ## Documentation Index
> Fetch the complete documentation index at: https://compact-by-example.org/llms.txt
> Use this file to discover all available pages before exploring further.

# First Application

> Build a counter DApp in Compact: the Counter ledger type, increment circuits, and public state on Midnight Network.

## Video Tutorial

<Frame>
  <iframe width="100%" height="400" src="https://www.youtube.com/embed/QWZMVp_0AIk" title="Counter DApp Tutorial" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />
</Frame>

## The Contract

<Accordion title="View Contract Code">
  ```compact theme={null}
  pragma language_version >= 0.23;

  import CompactStandardLibrary;

  // Public state visible on the blockchain
  export ledger round: Counter;

  // Circuit that increments the counter by 1
  export circuit increment(): [] {
    round.increment(1);
  }
  ```
</Accordion>

## How It Works

### Public Ledger State

```compact theme={null}
export ledger round: Counter;
```

`Counter` is a built-in type for counting operations. The value is publicly visible on the blockchain.

### The Increment Circuit

```compact theme={null}
export circuit increment(): [] {
  round.increment(1);
}
```

`Counter` stores a non-negative integer and exposes `.increment(n)`, `.decrement(n)`, `.read()`, and comparison helpers like `.lessThan(n)`. This example only uses `.increment(1)`.

## What's Next

<CardGroup cols={2}>
  <Card title="Primitive Types" icon="cube" href="/basics/primitive-types">
    Explore all Compact data types
  </Card>

  <Card title="Hello World" icon="hand-wave" href="/basics/hello-world">
    Back to the basics
  </Card>
</CardGroup>
