Skip to main content
Distributed Ledger StudioBlockchain for IoTExperimentsWorkspaces
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
BLOCKCHAIN FOR IoT · BC-M07
Blockchain for IoT

Mining, nonce search and double spending

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

HeaderNonce searchTarget
Design experiment & verify evidence →
BC-M07 · 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

Proof-of-work mining · nonce search

Teaching header encoding, real hash function and a bounded difficulty target
Teaching header encoding, real hash function and a bounded difficulty target

Scientific architecture · UTXO spending, mining nonce and block validation

UTXO spend and mining sequence — Input UTXO / 5 units; Outputs / payment 3, change 1.9; Fee / 5−3−1.9=0.1; Header nonce / hash target search; Validate / signatures, spend and header
Scientific concept map: UTXO inputs — Unspent outputs; Payment + change + fee — Conservation; Candidate block — Merkle root + header; Nonce search — Hash ≤ target; Validation — Link and spend checks.

Scientific foundations and analytical reasoning

UTXO inputs are consumed once; outputs plus fee equal input value. Proof of work searches header nonces against a target.

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.

BC-M07 · Academic orientation

Scope and objectives

Scope of the experiment

Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.

The focus of this experiment is to trace nonce search and synthetic proof-of-work acceptance. Students then compare transaction ordering and conflicting-spend scenarios, and explain confirmation assumptions without claiming absolute finality. 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 nonce search and synthetic proof-of-work acceptance.
  • Compare transaction ordering and conflicting-spend scenarios.
  • Explain confirmation assumptions without claiming absolute finality.
  • Identify the configured inputs (Available input (sat); Payment (sat); Fee (sat); Subsidy (sat); Attempt repeated spend) 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 nonce search and synthetic proof-of-work acceptance, compare transaction ordering and conflicting-spend scenarios, and explain confirmation assumptions without claiming absolute finality.

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 explain confirmation assumptions without claiming absolute finality. 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 Consensus algorithms and Byzantine disagreement.

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 · UTXO accounting and proof of work

An unspent transaction output is consumed as an input and new outputs are created. Sum(inputs)=sum(outputs)+fee; the same output cannot be spent twice in an accepted history. Proof of work searches candidate header values against a numeric target; each uniformly distributed hash has a corresponding success probability.

Worked example and engineering interpretation

An input of 10 units paying 6 with fee 1 requires change 3. A toy target of two leading hexadecimal zero digits has probability 1/256 per independent hash, with expected 256 attempts. A target match alone does not validate transactions or establish consensus.

Engineering principles · additional worked teaching example

A UTXO is an unspent output referenced by a transaction. Inputs equal outputs plus fee. With 9000 sat input, 5000 payment and 300 fee, change=3700 sat. A conflicting transaction cannot consume the same output in the same valid history.

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: Available input (sat) = 10000; Payment (sat) = 6000; Fee (sat) = 500; Subsidy (sat) = 312500; Attempt repeated spend = true; Required leading hex zeroes = 2; Maximum nonce attempts = 4096; Change mined block payload = false. In the classroom model, Spend accepted = Yes; Change output = 3500 sat; Repeat spend = Rejected: spent; Coinbase output = 313000 sat; Nonce attempts = 6; Target found = Yes. Transaction conservation and proof-of-work search are separate calculations. A valid-looking hash alone does not prove a ledger is canonical. Actual bounded SHA-256 search and simplified UTXO ledger; no cryptocurrency mining, real reward schedule or network consensus.

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 · independent state notebook

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.

Mining, nonce search and double spending: independent state notebook12345Calculated state 1Output / stateInputBefore10000AfterSTXO

Step 1 of 5 · Calculated state 1

Calculated state 1

Output / state
Input
Before
10000
After
STXO

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

How to investigate Mining, nonce search and double spending

Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.

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: Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.

  1. Enter 10,000 sat input, 6,000 sat payment and 500 sat fee. Verify change 3,500 sat and coinbase 313,000 sat in this example.
  2. Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear.
  3. Restore the spend. Use difficulty two leading hex zeroes and search bound 4096. Inspect attempted nonces and first qualifying hash (or bounded failure).
  4. Raise difficulty to three and reduce attempts to one. A search failure is not evidence that no valid nonce exists.

Reference check: Input equals recipient + change + fee on accepted spend; spent input cannot be reused. A nonce is accepted only if its hash meets the toy target.

Model boundary: Bounded single-miner SHA-256 search (max 25,000 attempts); no real mining or Bitcoin serialization; a valid nonce does not guarantee network acceptance.

Independent task and submission evidence

2. Inspect the UTXO→STXO transition and repeat-spend rejection. Raise payment to 10,000; no new outputs should appear. 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.

Model a UTXO spend and bounded proof-of-work nonce search using actual SHA-256. Observe change, fee conservation and reuse rejection.

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 a UTXO?

An unspent transaction output available under its spending rules.

How is change computed?

Input value minus recipient amount and fee.

What does the nonce search test?

Whether the actual candidate digest satisfies the chosen target condition.

Why is reuse rejected?

A successfully spent UTXO is removed from the available set.

What makes a mined block valid in this toy target check?

Its SHA-256 hexadecimal digest starts with the configured number of zeroes.

Is the nonce necessarily random?

No; it can be varied sequentially to search the input space.

Why bound the search?

It prevents unbounded computation in a browser while allowing a no-solution outcome.

What distinguishes a block reward from a transaction fee?

A reward may include new issuance; fees are allocated from transaction values according to protocol rules.

What must the recipient, change and fee sum to on an accepted spend?

The input value.

What happens when a previously spent input is submitted again?

It is rejected as already spent.

What does a difficulty of two leading hexadecimal zeroes require?

The candidate header digest must start with 00.

Does finding a valid nonce establish that all transactions are valid?

No. Transaction validation and proof-of-work target checking are separate checks.

BC-M07 engineering diagram
Engineering diagram · BC-M07. Use the interactive workstation to investigate the calculated state.
Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research