Introduction
An app can use rules to decide whether to accept a request and what
happens if it does.
What you’ll learn
Trace a contract action from an authorization check to a state
change.
Lesson
A smart contract defines which actions can change application state.
Think of a workshop reservation. Its state includes capacity, the number
of accepted reservations, and whether registration is open. A caller
requests a seat. The contract checks the conditions. If the action
succeeds, the state changes and an application can display the resulting
reservation.
A function or contract operation gives users a way
to request an action. An authorization check decides
which callers or proofs qualify. A log or event, in
platforms that support it, can help outside apps observe a result.
Solidity uses modifiers for reusable checks, while other languages offer
different tools for enforcing similar rules. The original code and any
paths for upgrades or configuration changes both matter when assessing
what users can rely on.
Worked example. The workshop has one seat left. Two
people apply. The action that is processed successfully first takes the
seat, and the next action must be checked against the new state. A
website showing one seat from a stale page cannot guarantee admission.
On Midnight, a suitable application might verify a proof that the
applicant holds an eligible credential while keeping its private fields
outside the public state. What the program reveals depends on what the
app includes in public outputs and sends elsewhere. See Midnight documentation.
Practice quiz
Select one answer per question.
Answer key and explanations
- C. In the rules that accept a reservation.
- A. An external source the application can evaluate
or trust.
- B. The result of the specific eligibility check,
subject to the app’s output design.
Sign in with Discord to take this quiz and earn your badge.