Skip to main content

Video Tutorial

The Contract

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

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

Primitive Types

Explore all Compact data types

Hello World

Back to the basics