Skip to main content

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.

Video Tutorial

The Contract

pragma language_version >= 0.16 && <= 0.18;

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);
}

How It Works

Public Ledger State

export ledger round: Counter;
Counter is a built-in type for counting operations. The value is publicly visible on the blockchain.

The Increment Circuit

export circuit increment(): [] {
  round.increment(1);
}
Increments the counter by 1. Counter values can only increase.

What’s Next

Primitive Types

Explore all Compact data types

Hello World

Back to the basics