Fundamentals

Chapter 1 / 15

Hello Contract

The simplest Covenant contract — record, action, view.


Every Covenant contract is a record: a typed bundle of persistent storage fields and the actions that modify them. This chapter builds the minimal contract — analogous to "Hello World" but running on an EVM chain.

hello.cov
record Hello {
    greeting: text;

    action update(new_greeting: text) {
        self.greeting = new_greeting;
        emit Updated(new_greeting);
    }

    view read() -> text {
        return self.greeting;
    }
}

Annotations

recorddeclares a contract with named storage fields.
textis Covenant's built-in string type, equivalent to string in Solidity.
actionis a state-mutating function — it produces a transaction.
viewreads state without modifying it; no gas cost when called off-chain.
emit Updated(...)emits a log event. The event type is inferred from the arguments.
self.greetingrefers to the contract's own storage field.

Key takeaways