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
record | declares a contract with named storage fields. |
text | is Covenant's built-in string type, equivalent to string in Solidity. |
action | is a state-mutating function — it produces a transaction. |
view | reads 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.greeting | refers to the contract's own storage field. |
Key takeaways
- Records are the primary contract abstraction in Covenant.
- Actions and views are declared at the same level — no
functionkeyword ambiguity. - The compiler infers ABI, storage layout, and event signatures automatically.