Skip to content
language.blue
repo.blue ↗Run this example

01 · Foundations

Counter Basics

Alice increments, Bob decrements, and one document records both operations. This is the smallest complete path from an authenticated Timeline Entry to deterministic execution and a new immutable revision.

Executable Playground example2 participants1 document2 guided actions

Why start here

One document. Two exact ways to act.

The Counter keeps business noise out of the way. Alice and Bob each have an attributed Timeline, each Timeline channel exposes only its declared operation, and every accepted request creates one new Root revision.

The central idea

A Timeline Entry is evidence that an action arrived. The document’s contracts decide whether and how that action changes state.

Alice Timeline ── increment(+3) ──┐
                                      ▼
                                 Counter Root
                                      ▲
Bob Timeline ───── decrement(1) ────┘

epoch 0: counter = 0
epoch 1: counter = 3  + event
epoch 2: counter = 2  + event

Run it

Follow the complete loop twice.

Guide pauses after every real operation so the participant, request, result, and resulting document state remain visible.

01
Inspect epoch 0.The Counter begins at zero and declares separate channels for Alice and Bob.
02
Act as Alice.Send the exact increment request. Coordination accepts the Timeline Entry and invokes the matching workflow.
03
Inspect epoch 1.See the state change, emitted event, processing gas, new BlueId, and previous-revision link.
04
Act as Bob.Decrement once and inspect the same deterministic boundary from a different authenticated channel.

What this teaches

The vocabulary used by every later example.

Participants, actors, Timelines, channels, operations, typed requests, BEX effects, events, epochs, and BlueIds all appear here in their smallest useful form.

IdentityThe Timeline channel authenticates the expected actor.
RoutingChannel plus operation selects one declared workflow.
ExecutionBEX returns changes and events as deterministic data.
HistoryEach result becomes a new immutable revision.
Next: make the execution boundary visible.

Continue with BEX Rules & Processing Gas to compare workflows and inspect their deterministic cost.