Last active
February 26, 2026 00:07
-
-
Save KBPsystem777/5b4d44365a7ffc45127a31594863cda0 to your computer and use it in GitHub Desktop.
DICT Activity: Reading a Smart Contract — Permit Registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This contract stores and manages building permits | |
| contract PermitRegistry { | |
| // STATE VARIABLES: Data this contract remembers | |
| address public officer; // Who is the authorized officer? | |
| uint public permitCount; // How many permits issued? | |
| // A 'struct' is a record template (like a government form) | |
| struct Permit { | |
| string applicantName; // Text: applicant name | |
| bool isApproved; // True/False: approved? | |
| uint issueDate; // Number: when issued | |
| } | |
| // FUNCTION: submit a new application | |
| function submitApplication(string memory name) public { | |
| require(bytes(name).length > 0, 'Name is required'); // VALIDATION | |
| permitCount = permitCount + 1; // STATE CHANGE | |
| } | |
| // FUNCTION: only the officer can approve | |
| function approvePermit(uint permitId) public { | |
| require(msg.sender == officer, 'Authorized officer only'); | |
| permits[permitId].isApproved = true; // STATE CHANGE | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment