Schemas

Sometimes your contract needs more than simple values. You might want to organize related data into a single shape, or define a fixed set of choices that never changes. let you do both.

Two Types of

A struct bundles related fields into one reusable shape. Think of it like a contact card: instead of storing a name, an email, and a phone number separately, you group them together so they always travel as a set.

For example, a “Member” struct might contain an account address, a display name, and a join date. Anywhere your contract needs to describe a member, it can use the struct instead of repeating each field individually.

An enum defines a fixed set of named choices. Once you create one, your contract can only pick from those specific options.

For example, a “Status” enum with the choices Active, Paused, and Closed gives your contract a clear, limited set of states. No guessing, no typos, just the options you defined.

Try It Yourself

The interactive panel below works just like the real editor. Complete each task to explore both types of .

Task 1 of 3 Create a Options List

Define a set of fixed choices your contract can pick from.

1 Add Options List
2 Name it "Status"
3 Add 3 options
4 Done!
Click + Add Options List below to create one.

Options Lists

A fixed set of named options to choose from

No enums defined yet.

What You Learned

By completing the tasks above, you explored two ways to define custom :

  • An enum (like “Status”): perfect for situations where only a few specific choices make sense, such as contract states or membership tiers
  • A struct (like “Member”): great for bundling related fields together, so you can treat them as a single unit throughout your contract
  • Adding fields to a struct: each field has a name and a type, letting you describe exactly what shape your data takes

These become building blocks for the rest of your contract. You can use structs as the type for stored data, and enums wherever you need a controlled set of choices.

Key Concepts

  • structs: Custom data shapes that bundle related fields together. Each field has a name and a type (like Number, Text, or Wallet Address).
  • enums: A fixed set of named choices your contract can pick from. The values never change after you define them.
  • Fields: The individual pieces of data inside a struct. Each field has a name (what it’s called) and a type (what kind of data it holds).
  • Reusability: Once defined, structs and enums can be used anywhere in your contract, just like built-in types such as Number or Text.