Skip to main content
FlowGuard is built on two BCH primitives: CashScript covenants (smart contracts that enforce spending conditions on UTXOs) and CashTokens (fungible tokens and NFTs native to BCH). Together they enable programmable finance with no custodian and no trusted server.

Core Primitives

Product Architecture

Every FlowGuard product follows the same pattern:
  1. Deploy — A covenant UTXO is created with parameters compiled into bytecode (immutable) and initial state in the NFT commitment (mutable).
  2. State Transitions — Each function call consumes the input UTXO, validates the transition, and produces a new UTXO with updated NFT state.
  3. Settlement — When the covenant reaches a terminal state (COMPLETED or CANCELLED), funds are distributed and the UTXO is consumed without replacement.

State Machine

All covenants share a common status field in their NFT commitment:
StatusValueDescription
ACTIVE0Normal operating state
PAUSED1Temporarily frozen by authority
CANCELLED2Terminated early, funds returned
COMPLETED3All obligations fulfilled
The CANCELLED status byte is 0x02 in the on-chain NFT commitment. Terminal states consume the covenant UTXO without producing a replacement NFT output.

Flags Bitmap

Every covenant has a flags byte in its NFT commitment at position [1]:
BitMaskMeaning
00x01FLAG_CANCELABLE — sender can cancel
10x02FLAG_TRANSFERABLE — recipient can transfer
20x04FLAG_USES_TOKENS — covenant holds CashToken FTs (not BCH)

Vault-Covenant Relationship

Covenants are linked to a Vault via vaultId compiled into the bytecode. This ties each streaming or distribution contract back to its treasury source for accounting and access control.