Protocol

A transaction protocol defines the message exchange pattern between parties. Each message carries a semantic payload: an offer, an acceptance, a confirmation, a rejection. The protocol specifies the order in which these messages may be sent, the conditions under which transitions are valid, and the guarantees the system provides when messages are lost or delayed.

protocol.define({
phases: ['offer', 'accept', 'confirm'],
timeout: '30s',
retries: 3,
on_failure: 'rollback'
});
OFFER ACCEPT CONFIRM ROLLBACK

State

Every transaction exists in a state. The state machine models the lifecycle: initialized, pending, committed, settled, or failed. Transitions between states are governed by protocol rules and external events. The state is the single source of truth for what a transaction is and what it may become.

const lifecycle = new StateMachine({
initial: 'initialized',
transitions: [
{ from: 'initialized', to: 'pending' },
{ from: 'pending', to: 'committed' },
{ from: 'committed', to: 'settled' }
]
});
INIT PENDING SETTLED FAILED

Consensus

In distributed transactions, consensus is the mechanism by which independent parties agree on a shared outcome without a central authority. The consensus algorithm must tolerate network partitions, message delays, and Byzantine failures -- any of which can cause honest participants to disagree about the current state of reality.

consensus.reach({
participants: nodes,
quorum: Math.floor(nodes.length * 2/3) + 1,
algorithm: 'practical-bft',
finality: 'deterministic'
});
N1 N2 N3 N4 N5

Settlement

Settlement is the irrevocable completion of a transaction. Once settled, the state cannot be unwound without a new, compensating transaction. Settlement transforms provisional commitments into permanent records. The finality guarantee is what distinguishes a true transaction from a mere promise.

await transaction.settle({
verify: true,
finality: 'absolute',
record: ledger.append(tx)
});
// settlement is irreversible
PENDING SETTLED LEDGER

API Surface

Transactions
State Machines
Consensus
Ledger
Analytics
Monitoring

dive deeper

INIT PROCESS VERIFY COMMIT SETTLE