VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Conditional Exchange Across Two Blockchains: Claims, Deadlines and Refund Paths

Three students in school uniforms work through open books at a classroom table, with textbooks and stationery nearby and study notes on the whiteboard behind them.

中文版 · Blockchain learning guide · Previous article

Blockchain learning · Extension BCX006

Three students in school uniforms work through open books at a classroom table, with textbooks and stationery nearby and study notes on the whiteboard behind them.
Study photograph for illustration; it does not establish that the pictured students are studying blockchain.

Two independent blockchains do not become one transaction simply because an application draws a line between them. A conditional exchange must explain what each ledger can enforce, when a participant learns enough to act, and what happens if the other participant stops. The order of the deadlines matters as much as the presence of a shared condition.

This lesson traces a complete, fictional two-ledger exchange. You will calculate successful claims, delayed responses, refund eligibility and a deadline design that fails even when both local contracts enforce their rules correctly. The goal is to inspect a coupled state machine rather than take the label “atomic” as a promise of simultaneous execution.

The amber and blue units below are invented classroom counters without monetary value, legal entitlement or external redemption. There are no real chains, accounts, keys, secret values, deployment instructions or exchange actions. Nothing here recommends a financial service or implies that one is available or permitted in a reader’s location.

Choose your reading route

In this guide

Sections 1–4 define the two commitments and every timing assumption. Sections 5–9 trace independent scenarios. Sections 10–12 test interpretation and assemble a model verdict. Use Blockchain Time and Deadlines for clock terminology. The present lesson concentrates on how two conditional transitions depend on each other.

Back to contents · Next section

1. Read each ledger’s promise before combining them

Participant A starts with four amber counters on fictional ledger L. Participant B starts with six blue counters on fictional ledger R. Their intended final allocation is B holding the four amber counters and A holding the six blue counters. The quantities express only the exercise’s allocation; they are not prices or claims of equal value.

A can place the four amber counters in commitment CL on L. CL designates B as the claim recipient and A as the refund recipient. B can place the six blue counters in commitment CR on R. CR designates A as the claim recipient and B as the refund recipient.

Once a commitment exists, its counters are unavailable for ordinary use while its state is Locked. A successful claim moves them to its designated claim recipient; a successful refund returns them to its designated original owner. Each commitment can reach only one terminal state, Claimed or Refunded.

L enforces CL’s rules and R enforces CR’s rules. Neither commitment automatically executes an action on the other ledger. Connecting their incentives and information flow requires additional protocol assumptions, which we will state rather than conceal inside a diagram.

Back to contents · Next section

2. Specify the shared witness without exposing a real secret

A initially knows an abstract witness W. Both commitments are supposed to contain the same hash condition h. The dossier supplies that W matches h, that the condition is checked correctly, and that B cannot learn or guess a matching witness before the stipulated disclosure. We provide no actual witness or hash bytes.

A successful claim on R publishes W in the fictional public execution record. B can then learn it and present it to L. Learning W alone does not transfer any counter: B must still have a valid claim executed on L while CL is Locked and its deadline condition permits it.

The recipient is fixed in each commitment. In this model, an unrelated observer who learns W cannot redirect the counters to themselves. This is a declared rule, not a conclusion drawn from the word “hashlock” alone. A different recipient or signature policy would require a different analysis.

Maurice Herlihy’s Atomic Cross-Chain Swaps studies conditional coordination with explicit timing and participant assumptions. Its discussion explains why publication order and staggered timeouts matter. We use that research as background, not as a claim that the particular simplified classroom machine below implements the paper’s complete protocol or proof.

Back to contents · Next section

3. Make the clock and terminal rules explicit

Both fictional ledgers use the same integer teaching clock t. An execution at t is irreversible immediately in this ideal model; there are no later reorganisations. These are strong supplied assumptions, not properties attributed to public blockchains or their wall clocks.

CL has deadline 20. CR has deadline 12. On either ledger, a claim succeeds only if the commitment is Locked, the claimant is its designated recipient, the witness matches, and execution time is strictly less than that commitment’s deadline. All these conditions are required.

A refund succeeds only if the commitment is still Locked, the actor is its refund recipient, and execution time is greater than or equal to its deadline. An eligible refund requires an action to be executed. Time passing alone does not change the stored state to Refunded.

At exactly the deadline, a claim is too late and a refund may be eligible. There is no overlapping claim/refund window in this rule. After either terminal transition, subsequent claims and refunds reject. A rejected action changes none of the tracked counters or commitment state.

Fees, rewards, price changes, administrative overrides and external legal effects are excluded. The local machines conserve their respective counter quantities. They do not convert amber into blue or make the two types fungible.

Back to contents · Next section

4. Check setup order and the response budget

A first establishes CL with the agreed recipient, condition, quantity and deadline. B verifies that actual irreversible commitment before establishing CR with the matching condition and agreed terms. A verifies both commitments before disclosing W through a claim on R. Each verification includes the identity of the ledger and commitment, not merely a screenshot of a familiar name.

For the successful response analysis, B is monitoring and follows the protocol. A valid claim on R becomes observable to B within at most two clock units. Once B observes it, B promptly submits its valid claim on L, which executes within at most another two clock units. Thus the total response budget from R execution to L execution is at most four.

Because time is integer and R claims require t less than 12, the latest eligible R execution is 11. The response bound then gives L execution no later than 15. Since 15 is less than 20, that response fits within CL’s claim window.

This calculation does not guarantee that A’s first claim will be included before 12. That requires its own successful execution evidence. It also does not guarantee that a participant who stops monitoring or delays voluntarily will recover in time. The protection demonstrated here depends on the supplied behaviour and bounds.

Back to contents · Next section

5. Scenario A: both claims complete, at different times

Start with both commitments correctly established and Locked. A’s valid claim on R executes at t=7. CR becomes Claimed and A receives six blue counters. CL is still Locked; B has not yet received the four amber counters. This intermediate state is part of the trace, not an error hidden by the final result.

Suppose B observes W at t=9 and its valid claim on L executes at t=11. Those delays are within the two-plus-two budget. Since 11 is less than 20, CL becomes Claimed and B receives four amber counters.

The terminal allocation is A with six blue counters and B with four amber counters. Each ledger conserves its own type: there are still four amber and six blue counters across owners and commitments. Both commitments have released their locked counters, and neither can refund afterward.

The executions occurred at 7 and 11, not simultaneously. A joint user-interface status should retain both records and their times. Calling the final outcome a completed conditional exchange does not justify inventing a single cross-ledger execution receipt.

Back to contents · Next section

6. Scenario B: no disclosure, followed by explicit refunds

Reset to the independent state with both commitments Locked. A never discloses W, and no matching witness otherwise becomes known. No claim occurs. At t=12, CR’s refund predicate becomes eligible for B, but CR remains Locked until a refund action executes.

B’s refund executes at t=13. CR becomes Refunded and B regains six blue counters. CL remains Locked because its deadline is 20. At t=21, A’s refund executes, CL becomes Refunded and A regains four amber counters.

The terminal allocation matches the initial one: A has four amber and B has six blue. The exchange did not complete. The counters were unavailable for ordinary use during their respective lock periods, so “no exchange occurred” does not mean “nothing was affected.”

For a separate observation at t=25 with neither refund action executed, both commitments remain Locked but refund-eligible. Do not report that the owners have already received the counters. Eligibility, submitted action, executed transition and terminal ownership are separate facts.

Back to contents · Next section

7. Scenario C: equal deadlines remove the response margin

Reset again and change only CL’s deadline from 20 to 12. CR’s deadline stays 12. Suppose A’s valid R claim executes at t=11, the last eligible integer time. A receives six blue counters and W becomes available through the stated observation process.

B observes W at t=13. This still satisfies the two-unit observation bound. However, CL’s claim window has already closed. A can have a valid refund on L executed at t=12, returning the four amber counters to A. B’s later claim cannot succeed because CL is Refunded and, independently, the deadline has passed.

A then holds both the original four amber and the claimed six blue counters, while B has neither allocation. Both local commitments followed their declared rules. The defective result arises from their coupled deadline design, not from a local hash-check failure.

This is a counterexample to “matching hash conditions and equal deadlines are enough.” It does not assert that every possible equal-deadline design is equivalent to this machine. It shows exactly why this specified design fails to give B the response opportunity supplied by the original staggered deadlines.

Back to contents · Next section

8. Scenario D: the response bound fails

Restore CL’s deadline 20 and CR’s deadline 12. A’s R claim executes at t=11. B observes W at t=13 and promptly submits its L claim. Now change the environment: the L action does not execute until t=26. This violates the assumed maximum two units from observation to execution.

Meanwhile, A’s eligible refund executes on L at t=20. CL becomes Refunded. B’s action at 26 rejects because the commitment is terminal and its claim deadline is past. A retains four amber counters and has already received six blue; B’s outgoing blue allocation is gone without the intended amber receipt.

The conclusion is not that the earlier arithmetic was wrong. Its premise was false in this scenario. A deadline gap sized for a four-unit total response cannot establish protection when the actual response takes fifteen units after R execution.

Similarly, removing the immediate-irreversibility assumption would require a fresh analysis of what observations are safe to act upon and how finality delay fits the budget. We do not simply add the word “confirmed” to restore a guarantee. No probabilistic or production finality claim is supplied here.

Back to contents · Next section

9. Scenario E: disclose before the reciprocal commitment exists

Start with only CL established and Locked. CR does not exist. Contrary to the setup rule, A makes W available to B. B’s valid claim on L executes at t=5, before deadline 20, and CL becomes Claimed.

B receives four amber counters. A has no reciprocal CR from which to claim six blue counters. Knowledge of W cannot create that missing commitment. A also cannot refund CL later because it is already Claimed.

This case explains the instruction to verify the reciprocal commitment before disclosing. The rule concerns actual state and terms, not an informal promise that B will create the other side afterward. A screenshot, proposed transaction or incomplete draft is not the stipulated irreversible CR.

An independent setup defect would put a different hash condition in CR. A should reject that setup rather than assume W works on both sides. A matching label or intended business purpose does not establish matching machine conditions. No claim or disclosure is performed in this rejected-setup variant.

Back to contents · Next section

10. Check conservation and distinguish local from coupled safety

Within the normal trace, four amber counters move from A to CL to B; six blue move from B to CR to A. Within the refund trace, each type returns to its original owner. Nothing creates or destroys counters in either trace.

Conservation alone is too weak to validate the exchange protocol. The equal-deadline and broken-delay scenarios also conserve four amber and six blue while producing the unwanted allocation. A test that checks only total supply would pass those scenarios and miss the problem the participants care about.

Likewise, “a commitment cannot be claimed and refunded” is a useful local invariant but not the complete coupled argument. You also need setup order, witness availability, deadline order, response behaviour and the relevant finality and delivery assumptions.

The cross-chain message acceptance lesson examines remote evidence and message identity. Accepting one remote message does not by itself prove the reciprocal timeout and recovery properties traced here.

Back to contents · Next section

11. Build a review verdict with visible limits

A useful verdict identifies both ledger contexts, commitment terms, fixed recipients, initial locked quantities, hash-condition relationship and terminal rules. It then records the actual execution evidence, rather than using submission time as the deadline test.

For the original fixture, write: “The given response bound leaves B time to claim L after any eligible integer-time claim on R, provided B follows the response procedure and all stated clock, execution and irreversibility assumptions hold. The normal trace completes at two distinct times. The no-disclosure trace requires separate refund actions and does not complete the exchange.”

Add the counterexamples: “Equal deadlines permit the supplied one-sided allocation even within the observation bound. Exceeding the response bound invalidates the original protection argument. Premature disclosure before CR exists defeats the setup procedure. Local conservation does not exclude these outcomes.”

That is a conclusion about this dossier. It is not a blanket recommendation for a protocol, service or legal arrangement. It also leaves implementation correctness, monitoring availability, real-network timing and operational costs outside the demonstrated result.

Back to contents · Next section

12. Exercise with worked answers

Treat each question as independent unless it explicitly refers to a preceding state.

  1. Under the original deadlines, may A claim R at execution time 12? No. The rule is strictly less than 12. A submission at 11 does not change an execution-time rejection at 12.
  2. If A claims R at 11 and the full response budget is used, when can B’s L claim execute? By 15. This is before L’s deadline 20.
  3. After the normal R claim at 7 but before the L claim at 11, are both commitments Claimed? No. CR is Claimed and CL is still Locked.
  4. At time 25 with no disclosure and no refund actions, what are the states? Both remain Locked and refund-eligible. The counters have not yet returned.
  5. Can B claim CL after A’s refund has executed? No. Refunded is terminal, even if B now knows W.
  6. In the equal-deadline case, does a correct hash check rescue B at 13? No. The deadline and terminal-state requirements are additional conditions.
  7. Does extending L’s deadline to 30 prove safety under arbitrary delay? No. A finite deadline cannot establish this response argument without a corresponding justified bound and the other assumptions.
  8. Does A’s possession of six blue counters prove a legal right to an external object? No. The exercise assigns no external entitlement to its counters.

For an extra calculation, consider an independent CL deadline of 15 while CR remains 12. The latest eligible R claim is 11 and the supplied response can take four units, reaching exactly 15. Because the L claim rule is strict, this is insufficient. A bound that reaches the deadline is not the same as a bound that remains before it.

Back to contents · Next section

Frequently asked questions

Does atomic mean both chains execute at the same instant?

That is not demonstrated here. The successful trace has distinct execution times and an intermediate state. Any atomicity claim must be read with its protocol definition and assumptions.

Does a timeout automatically refund the owner?

Not in this machine. It enables an owner-authorised refund action while the commitment remains Locked. The action still has to execute.

Is learning the witness equivalent to receiving the counters?

No. The recipient must still satisfy the local claim conditions and obtain execution before the deadline. Correct information is only one part of the transition.

Why not choose a very long deadline and stop worrying?

A longer lock changes how long counters may remain unavailable. It does not establish truthful observations, bounded execution, correct setup or finality. Timing choices need a justified model, not a reassuringly large number.

Back to contents · Next section

Sources and further reading

  • Maurice Herlihy, Atomic Cross-Chain Swaps: first submitted 29 January 2018; version 4 revised 18 May 2018. Metadata checked 12 October 2026.
  • Full paper, version 4: theoretical background on timing assumptions, publication order and timeout separation; checked 12 October 2026. The classroom counters, times and transition rules above are separately supplied examples, not reproduced implementation code.
  • Blockchain Time and Deadlines: companion lesson on which clock and comparison a rule actually uses.
  • Cross-Chain Message Acceptance: companion evidence task for message identity and destination acceptance.

The useful question is not merely whether two commitments share a condition. It is whether the complete sequence leaves each conforming participant a valid next action under the assumptions the system actually provides.

Back to contents