Skip to content

Instantly share code, notes, and snippets.

@KBPsystem777
Last active February 26, 2026 00:07
Show Gist options
  • Select an option

  • Save KBPsystem777/5b4d44365a7ffc45127a31594863cda0 to your computer and use it in GitHub Desktop.

Select an option

Save KBPsystem777/5b4d44365a7ffc45127a31594863cda0 to your computer and use it in GitHub Desktop.
DICT Activity: Reading a Smart Contract — Permit Registry
// 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