Skip to main content
Cyber Defense StudioIoT Security and PrivacyExperimentsWorkspaces
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
BLOCKCHAIN FOR IoT · BC-M10
Blockchain for IoT

Solidity, Remix and access control

Dr. Mohammad Alja’afreh · Princess Sumaya University for Technology

CallerOwner guardMapping
Design experiment & verify evidence →
BC-M10 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice

← Lecture-aligned module experiments · All blockchain labs · Setup wizard

Introduction

Solidity authorization and storage

A contract write must pass checks before persistent state is changed
A contract write must pass checks before persistent state is changed

Scientific architecture · Solidity access, arithmetic, ABI and oracle behavior

Solidity caller, ABI and state — ABI call / selector and arguments; Decode / typed arguments; Modifier / authorization; Execute / storage or oracle input; Receipt / log only on successful execution
Scientific concept map: Solidity interface — Function selector; Caller and arguments — ABI encoding; Modifier — Role / state guard; Contract storage — Mapping and variables; Event — Receipt and logs.

Scientific foundations and analytical reasoning

Solidity authorization and checked arithmetic govern state transitions; oracle freshness is an application rule. External calls can transfer control.

Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.

Related course access: IoT Security and Privacy — same laboratory, notebook and completion record.

BC-M10 · Academic orientation

Scope and objectives

Scope of the experiment

Trace owner checks, mapping writes and emitted events. Compile and deploy a real small Solidity registry using Remix VM.

The focus of this experiment is to trace Solidity types, visibility and access-control checks. Students then predict state changes for authorized and unauthorized calls, and verify local Remix transactions and inspect revert evidence. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.

Learning objectives

  • Trace Solidity types, visibility and access-control checks.
  • Predict state changes for authorized and unauthorized calls.
  • Verify local Remix transactions and inspect revert evidence.
  • Identify the configured inputs (Function / experiment; msg.sender; Stored uint8; Increment / requested withdrawal; Oracle data age (s)) and record the corresponding observed outputs with units where applicable.
  • Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.

Expected learning outcomes

On completion, students can trace Solidity types, visibility and access-control checks, predict state changes for authorized and unauthorized calls, and verify local Remix transactions and inspect revert evidence.

Required deliverables

Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify local Remix transactions and inspect revert evidence. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the foundational terminology in Concepts and confirm readiness using the existing setup instructions. After completion, continue to Blockchain for IoT: food cold-chain traceability.

Environment and experimental methodology

The listed browser model and experiment-specific local Python, Solidity or EVM workflow, where provided. Do not treat a model as a deployed ledger.

Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.

Scientific theory · Solidity semantics and access control

Solidity contract storage persists across successful transactions; memory and calldata have different lifetimes and mutability. ABI encodes calls and return values. Modifiers enforce caller or state predicates, while events provide logs. Oracle freshness must be explicitly checked; external calls create additional control-flow boundaries.

Worked example and engineering interpretation

An owner-only setter must reject a non-owner without changing storage. A fresh authenticated sensor value can pass a defined timestamp rule, while a stale one must not. In Remix's local VM, inspect the actual compiler result, receipt, storage and event rather than infer execution from the source.

Engineering principles · additional worked teaching example

Solidity state persists across transactions; msg.sender identifies the immediate caller. In Solidity 0.8 checked arithmetic, uint8 ranges 0…255; adding 10 to 250 reverts unless explicitly unchecked. Reverts roll back state.

From theory to experiment

Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Function / experiment = increment; msg.sender = owner; Stored uint8 = 20; Increment / requested withdrawal = 10; Oracle data age (s) = 20; Maximum oracle age (s) = 60; Arithmetic policy = checked; Withdrawal ordering = checks-effects-interactions; External callback attempted = true. In the classroom model, Execution = Committed; State = 30; Event = ValueUpdated(30); Callback result = Not applicable. This represents the selected contract behavior explicitly. Compile and execute the actual Solidity source in Remix to verify bytecode and receipts. Typed state-machine model, not Solidity compilation or EVM execution. The withdrawal ordering is a defensive conceptual model, not an exploit or a live contract.

Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.

Concept animation · operation pathway

Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.

Solidity, Remix and access control: operation pathwayModifierPassTyped calculation /oracleEvaluatedStorage30EventValueUpdated(30)Read the active operation, then inspect the accumulated state.

Step 1 of 4 · Modifier

Modifier

Modifier
Pass

Teaching example only; inspect live calculations or real practical evidence separately.

How to investigate Solidity, Remix and access control

Trace owner checks, mapping writes and emitted events. Compile and deploy a real small Solidity registry using Remix VM.

Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.

Experiment-specific guided practice

Objective: Trace owner checks, mapping writes and emitted events. Compile and deploy a real small Solidity registry using Remix VM.

  1. Run increment with owner, stored uint8 20, increment 10 and checked arithmetic. Inspect the function signature, input arguments, new value and event.
  2. Choose guest; the only-owner fixture rejects before arithmetic and no event is emitted.
  3. Set value 250 and increment 10. Compare checked revert with unchecked wrap to 4. Identify why uint8 cannot represent 260.
  4. Select setOracle and set age 90 against maximum 60; the stale data must not update state. Restore a fresh reading.

Reference check: Owner call updates mapping and emits DeviceStatus; outsider call reverts and leaves state unchanged. Save the actual Remix transaction receipts separately.

Model boundary: Browser is a state-machine model, not a Solidity compiler or EVM. Solidity 0.8 uses checked arithmetic by default; do not use selfdestruct as a general upgrade mechanism.

Independent task and submission evidence

2. Choose guest; the only-owner fixture rejects before arithmetic and no event is emitted. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.

Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.

Trace owner checks, mapping writes and emitted events. Compile and deploy a real small Solidity registry using Remix VM.

Learning goals

  1. Explain the mechanism using the actual intermediate states in this experiment.
  2. Predict and verify the reference and modified conditions described below.
  3. Interpret the acceptance criteria and identify the limits of the model.

Module flashcards · 12 questions

Browse all 12 questions and explanations
What is msg.sender?

The immediate caller of the Solidity execution context.

What does a mapping represent?

Key-to-value storage with default values.

What is emitted on successful setDevice?

A DeviceStatus event.

What is the distinction between ABI and bytecode?

The ABI describes interfaces; bytecode is executable EVM code.

What is a function modifier used for?

Reusing a precondition such as access control before function execution.

What should a non-owner registry write do?

Revert without updating state or committing a success event.

Why use Remix VM?

To compile and execute contracts in a local simulated blockchain environment without real Ether.

What is the checks-effects-interactions pattern?

Validate conditions, update state, then perform external calls to reduce reentrancy risk.

What changes after the owner calls setDevice successfully?

The device mapping is updated and DeviceStatus is emitted.

What should remain unchanged when an outsider calls setDevice?

The contract state, because the access check reverts the call.

Which caller identity is checked by the contract?

msg.sender.

What evidence distinguishes an actual Remix VM execution from the browser model?

A transaction receipt and observed contract state from Remix VM.

Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research