Skip to main content

The Contract

pragma language_version 0.16;

import CompactStandardLibrary;

// On-chain storage for the message
export ledger message: Opaque<"string">;

// Store a new message
export circuit storeMessage(customMessage: Opaque<"string">): [] {
    disclose(message = customMessage);
}

// Retrieve the current message
export circuit getMessage(): Opaque<"string"> {
    return message;
}

How It Works

Pragma Directive

pragma language_version 0.16;
Specifies the compiler version.

Import Statement

import CompactStandardLibrary;
Provides essential types and functions.

Ledger Declaration

export ledger message: Opaque<"string">;
Declares on-chain state. Opaque<"string"> stores variable-length strings.

Circuits (Functions)

export circuit storeMessage(customMessage: Opaque<"string">): [] {
    disclose(message = customMessage);
}
Circuits are functions callable from external applications. [] means returns nothing.

The disclose() Function

disclose(message = customMessage);
Use disclose() when assigning user input to ledger variables to make data public.

What’s Next