Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Distributed Ledger StudioBlockchain for IoTExperimentsWorkspaces
ENGINEERING WORKSPACE
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
BLOCKCHAIN FOR IOT
Blockchain for IoT

B04 · Solidity fundamentals with Remix

Ask Dr. Mohammad · B04 →

Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

Design experiment & verify evidence →
B04 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Blockchain foundationsB04 · Solidity fundamentals with Remix

Before you start

Learning outcome: Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

Use fictional values only. Browser models work offline; actual Solidity compilation and Remix VM require the external Remix IDE and initial compiler download. No real funds or private credentials.

Recommended predecessors: B03

Predict: Write down the expected positive and negative outcomes in the notebook before proceeding.
B04 · Academic orientation

Scope and objectives

Scope of the experiment

Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

The focus of this experiment is to interpret Solidity types, storage variables and function execution. Students then predict state changes and reversion for specified inputs, and verify local Remix deployment and transaction results. 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

  • Interpret Solidity types, storage variables and function execution.
  • Predict state changes and reversion for specified inputs.
  • Verify local Remix deployment and transaction results.
  • Identify the configured inputs (Initial counter; Function sequence) 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 interpret Solidity types, storage variables and function execution, predict state changes and reversion for specified inputs, and verify local Remix deployment and transaction results.

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 deployment and transaction results. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to B05 · IoT device registry and access control.

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.

Understand the experiment

Scientific architecture · Solidity counter state and events

Counter contract state — Storage / count=0; Call increment / authorized transaction; Execute / count=1; Event / new value; Receipt / success and gas
Scientific concept map: Remix VM — Deploy Counter; Transaction — Caller / arguments; Contract function — Increment or read; Storage — Persistent value; Receipt — Event and status.

Scientific foundations and analytical reasoning

Contract reads inspect state; successful transactions may modify it and emit events. Reverted writes do not persist.

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.

Scientific theory · Contract execution and state

A smart contract executes deterministic code on blockchain state. Reads inspect state without a state-changing transaction in the usual RPC call model; writes require a transaction and successful execution. Events describe emitted logs and are not themselves authoritative storage. A revert rolls back contract writes.

Worked example and engineering interpretation

If a counter starts at 5 and an authorized increment of 2 succeeds, state becomes 7. An invalid call that reverts leaves it at 7, even if gas was consumed. Compare receipt status, emitted events and a subsequent state read using the local environment.

Engineering principles · additional worked teaching example

Contract storage persists; a read returns current state without mutation. Starting counter3, increment twice gives5; read returns5; authorized reset sets0. Reverting a call preserves prior 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.

How to investigate B04 · Solidity fundamentals with Remix

Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

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: Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

  1. Run increment;increment;read;reset starting at zero. Inspect before/after count and three write events.
  2. Choose read;read and confirm no state mutation or write events.
  3. Choose three increments and change initial count to 5. Predict the final count before checking.
  4. Create and compile the counter contract in Remix VM, deploy once, execute the same calls and inspect events and transaction receipts.

Reference check: Read-only local call does not pay a transaction fee. Failed included transactions can consume gas without committing contract state.

Model boundary: Fixed illustrative gas costs, not measured EVM gas. Use actual receipts in Remix for precise costs.

Independent task and submission evidence

2. Choose read;read and confirm no state mutation or write events. 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.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Initial counter = 0; Function sequence = increment;increment;read;reset. In the classroom model, Final count = 0; Write events = 3. The model changes storage only on a writing function. Counter state model; actual compilation and deployment require Remix.

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 · progressive data plot

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.

B04 · Solidity fundamentals with Remix: progressive data plot00.511.52Stored counterinitialresetinitial

Step 1 of 5 · Observation initial

Observation initial

Stored counter
0

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

Recall the concept before revealing its explanation.

0 / 3 revealed
B04 · 01 / 08What is a contract?Reveal explanation
Engineering explanation

Executable code and persistent state at a blockchain address.

B04 · 02 / 08What is a view call?Reveal explanation
Engineering explanation

A call that does not modify state; an off-chain eth_call does not require a paid transaction.

B04 · 03 / 08What does gas measure?Reveal explanation
Engineering explanation

EVM resource consumption; actual fees depend on gas used and gas price.

B04 · 04 / 08How does a view call differ from a state-changing transaction?Reveal explanation
Engineering reasoning

A view call reads state; a successful state-changing transaction updates state after execution and is checked with a receipt/readback.

B04 · 05 / 08Why verify the counter after both increment and reset?Reveal explanation
Engineering reasoning

It verifies two independent state transitions rather than merely assuming successful compilation establishes behavior.

B04 · 06 / 08A Solidity variable is read and then updated. Select every technically valid statement. A. A read-only call need not create an on-chain transaction. B. A state-changing transaction needs confirmation and execution checks. C. Every read creates a mined state change. D. Compilation proves every runtime authorization property.Reveal explanation
Applied scenario

Correct: A. A read-only call need not create an on-chain transaction.; B. A state-changing transaction needs confirmation and execution checks.

B04 · 07 / 08How do you carry out 4. Verify state and events?Reveal explanation
Implementation recall

Click count, increment twice, click count again, reset and count. Inspect the transaction receipts and CountChanged events.

B04 · 08 / 08For B04 · Solidity fundamentals with Remix, which actual output or state confirms the prescribed practical run succeeded, and what does it not establish?Reveal explanation
Evidence & acceptance

Open Remix IDE with internet for initial compiler download. Create/upload Counter.sol; choose compiler 0.8.28, Shanghai EVM target and optimization off. Deploy & Run: choose Remix VM with compatible fork, account 0, VALUE 0 and Counter. Deploy then expand deployed instance. count=0; increment twice then count=2; reset then count=0. Inspect successful transaction receipts and CountChanged events. Read calls do not change state; no real funds/wallet.

Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research
Loading experiment-specific apparatus…
Previous model / additional reference tools
Simulation task

Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions.

Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.

Interactive engineering workbenchB04 · Existing model

Interactive simulation

The model is an independent teaching abstraction, not Solidity execution or Ethereum consensus. SHA-256 uses actual browser cryptography when available.

Loading executable simulation…

B04 · Model-linked instrumentation

Visual observation lens

Back to controls ↑

Browser ledger / digest abstraction; not EVM transaction execution.

Loading instrument…

Awaiting model display.

Experimental instrumentation · A/B

Compare two model conditions

Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.

Open simulation view
Baseline A
Not captured
Comparison B
Not captured

Capture a baseline to begin.

Evidence portfolio →
V19.0 · Contextual AI workspace

Ask your engineering assistants

B04 · current context

Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.

Dr. Mohammad · offline
Dr. Mohammad

Offline curriculum-grounded assistance.

Open local tutor
B04 · Solidity fundamentals with Remix

Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.

Prepare a contextual AI prompt

0 characters

Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.

Prepare → review → copy & open your selected provider → paste and submit there.

Run & verify — acceptance checklist

Build verification: Counter model tested; actual Solidity compilation/EVM pending.

Open Remix IDE with internet for initial compiler download. Create/upload Counter.sol; choose compiler 0.8.28, Shanghai EVM target and optimization off. Deploy & Run: choose Remix VM with compatible fork, account 0, VALUE 0 and Counter. Deploy then expand deployed instance. count=0; increment twice then count=2; reset then count=0. Inspect successful transaction receipts and CountChanged events. Read calls do not change state; no real funds/wallet.

Record the actual output, source (mock/model or physical), and any error. A missing tool, timeout or untested external service is not a pass.

Complete lab-by-lab verification report →Open automated verification center → Ask Engineering Copilot →

Independent theoretical exercises

Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.

01 · Predict and derive using the given inputs

Trace increment;increment;read;reset from 0, recording state before/after and which operations are reads.

02 · Compare or justify using evidence

Explain why a local read can be free of transaction fees but a state-changing transaction consumes gas; identify evidence from a receipt.

03 · Execution tracing

Execution tracing · Independent work

Start counter4; execute increment, read, reset, read, increment. List values after every step.

Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.

Expanded independent theoretical exercise bank

Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.

Intermediate · Explain a changed-input result

Independent theoretical exercise · B04-01

Use the reference configuration (Initial counter = 0; Function sequence = increment;increment;read;reset), but change Function sequence = reset;increment;read. The model reports Final count = 1. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

Intermediate · Quantitative comparison

Independent theoretical exercise · B04-02

Two model observations of Final count are 0 (reference) and 1 (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.

Intermediate · Interpret a technical trace

Independent theoretical exercise · B04-03

For Function sequence = read;read, the model supplies this excerpt from Function calls: Step · Function · Before · After · Event 1 · read · 0 · 0 · None 2 · read · 0 · 0 · None Count rows whose Function value is exactly “read”, and identify the displayed row numbers. Explain what the count describes.

Advanced · Reverse reasoning

Independent theoretical exercise · B04-04

An observation is Write events = 0. Candidate A uses Initial counter = 0; Function sequence = increment;increment;read;reset. Candidate B changes the listed settings (Function sequence = read;read) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.

Advanced · Diagnose a reported mismatch

Independent theoretical exercise · B04-05

A student configures Function sequence = increment;increment;increment while preserving all other reference settings, but copies the reference report of Final count = 0. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

Challenging · Design a controlled verification

Independent theoretical exercise · B04-06

Design a controlled comparison for B04 · Solidity fundamentals with Remix using reference Initial counter = 0; Function sequence = increment;increment;read;reset and test Function sequence = reset;increment;read. Specify the changed setting(s), measured metric Final count, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

Step-by-step experimental procedure

Trace each counter call and compare view versus writing functions.

1 · Reference workbench configuration

Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.

Initial counter0
Function sequenceincrement;increment;read;reset

2 · Perform the investigation in order

  1. Run increment;increment;read;reset starting at zero. Inspect before/after count and three write events.
  2. Choose read;read and confirm no state mutation or write events.
  3. Choose three increments and change initial count to 5. Predict the final count before checking.
  4. Create and compile the counter contract in Remix VM, deploy once, execute the same calls and inspect events and transaction receipts.

3 · Compare controlled trials

TrialIndependent changeExpected checkObservation
Increment twice, read, resetUse reference inputs aboveFinal count: 0; Write events: 3Record actual result
View onlyFunction sequence = read;readWrite events: 0Record actual result
Three incrementsFunction sequence = increment;increment;incrementFinal count: 3; Write events: 3Record actual result

4 · Analyze and report

Why does a view call differ from a state-changing transaction?

Required evidence: Function-call table and EVM receipt observations.

Model boundary: Counter state model; actual compilation and deployment require Remix.

Controlled investigation · reproducible evidence

Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.

TrialIndependent changeDependent observation
Increment twice, read, resetUse reference inputs aboveRecord actual outcome and units
View onlyFunction sequence = read;readRecord actual outcome and units
Three incrementsFunction sequence = increment;increment;incrementRecord actual outcome and units

Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.

Loading laboratory-specific procedure…

Independent implementation sequence

  1. 1. Practice state transitions
  2. 2. Create and compile the contract
  3. 3. Deploy locally
  4. 4. Verify state and events

Complete practical procedure

Open Remix IDE ↗ · Official deployment guide

1. Practice state transitions

Use the model to increment twice, read count, and reset.

✓ Expected: Count becomes 2 then 0; read does not change state.

2. Create and compile the contract

Open Remix, create Counter.sol, paste or upload the packaged file. Select compiler 0.8.28, Shanghai target and optimization off. Compile Counter.sol.

✓ Expected: Compilation succeeds without errors; Counter appears in the contract selector.

3. Deploy locally

Open Deploy & Run Transactions, choose Remix VM (a compatible fork), account 0, VALUE 0, Counter, Deploy.

✓ Expected: A successful deployment receipt and a deployed Counter instance appear.

4. Verify state and events

Click count, increment twice, click count again, reset and count. Inspect the transaction receipts and CountChanged events.

✓ Expected: 0, then 2, then 0. Increment/reset generate transactions; count reads state.

Experimental notebook

Record your own results. Values are not prefilled or independently verified.

Source & scientific method

The model is independent of the actual Solidity source. Counter intentionally permits any account to increment/reset; it is not an access-controlled contract.

Counter.sol

Download source file
Solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
/// @notice Teaching contract: no Ether or external calls.
contract Counter {
    uint256 public count;
    event CountChanged(uint256 value);
    function increment() external { count += 1; emit CountChanged(count); }
    function reset() external { count = 0; emit CountChanged(count); }
}

Toolkit instructions and references · Download complete blockchain toolkit

Verification, troubleshooting and reflection

Compare each observation with its expected result. If a check fails, identify whether the issue is the environment, contract selection, caller identity, sequence, byte encoding or model setup. Do not infer success from a timeout or a missing receipt. In Remix inspect the compiler errors and revert message; do not bypass the negative control.

Reset the browser model for a fresh run. Resetting Remix VM removes its deployed state. Keep screenshots and receipts before reset. For actual EVM execution, save compiler/fork/settings and transaction receipts. Explain limitations and propose one additional independent test.

Python / Google Colab laboratory

B04 · 9 notebook cells · 2 executable Python cells

Complete the theoretical investigation first. Run the cells in order, record actual outputs and compare against your prediction.

How to execute

  1. Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
  2. Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
  3. Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.

Execution scope: Fixed illustrative gas costs, not measured EVM gas. Use actual receipts in Remix for precise costs. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.

01Instructions · Markdown
# B04 · B04 · Solidity fundamentals with Remix **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## 1. Scientific objective Trace each counter call and compare view versus writing functions. Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation Compile, deploy and call a simple Solidity state variable and distinguish reads from transactions. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Run increment;increment;read;reset starting at zero. Inspect before/after count and three write events. 2. Choose read;read and confirm no state mutation or write events. 3. Choose three increments and change initial count to 5. Predict the final count before checking. 4. Create and compile the counter contract in Remix VM, deploy once, execute the same calls and inspect events and transaction receipts. **Evidence:** Read-only local call does not pay a transaction fee. Failed included transactions can consume gas without committing contract state. **Boundary:** Fixed illustrative gas costs, not measured EVM gas. Use actual receipts in Remix for precise costs.
03Instructions · Markdown
## 2. Reference configuration and investigation 1. Run increment;increment;read;reset starting at zero. Inspect before/after count and three write events. 2. Choose read;read and confirm no state mutation or write events. 3. Choose three increments and change initial count to 5. Predict the final count before checking. 4. Create and compile the counter contract in Remix VM, deploy once, execute the same calls and inspect events and transaction receipts. Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
## 3. Trace a counter contract model, not an EVM.
05Python · executable cell
PYTHON · Code cell
# =====================================================================
# B04 | Code cell 01 | B04 · Solidity fundamentals with Remix
# Purpose: 3. Trace a counter contract model, not an EVM.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation calls; keep its logic separate from the trial.
def calls(sequence):
    count=0; events=[]
    for call in sequence:
        if call=="increment":count+=1;events.append(count)
        elif call=="reset":count=0;events.append(count)
        print(call,count)
    return count,events
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert calls(["increment","increment","read","reset"])==(0,[1,2,0])
Ask Dr. Mohammad about this cell
06Instructions · Markdown
## 4. Compare view calls. Use Remix for actual Solidity.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# B04 | Code cell 02 | B04 · Solidity fundamentals with Remix
# Purpose: 4. Compare view calls. Use Remix for actual Solidity.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert calls(["read","read"])==(0,[])
Ask Dr. Mohammad about this cell
08Instructions · Markdown
## Experimental analysis and submission 1. Record the reference input, predicted output and actual result. 2. Modify one independent variable and run the relevant cells again. 3. Explain the result using the theory and identify model limitations. 4. Save the notebook with outputs and retain the separate theoretical worksheet. **Your derivation and conclusion:** (Complete independently.)
09Instructions · Markdown
## Guided reasoning and evidence A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above. **Independent task:** 2. Choose read;read and confirm no state mutation or write events. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat. | Trial | Input/configuration | Prediction | Observation | Evidence / limitation | |---|---|---|---|---| | A | Reference | | | | | B | Changed input | | | | | A repeat | Reference | | | | A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.