Data Structures

The contract stores data in maps and data variables.

Maps

escrows

Primary escrow storage, keyed by escrow ID.

clarity
(define-map escrows uint { buyer: principal, seller: principal, amount: uint, fee-amount: uint, description: (string-utf8 256), status: uint, token-type: uint, created-at: uint, expires-at: uint, completed-at: uint, disputed-at: uint })
FieldTypeDescription
buyerprincipalAddress that created and funded the escrow
sellerprincipalAddress that receives funds on release
amountuintPrincipal amount (excluding fee)
fee-amountuintPlatform fee calculated at creation
descriptionstring-utf8 256Human-readable description
statusuintCurrent state (0=Pending, 1=Released, 2=Refunded, 3=Disputed)
token-typeuint0=STX, 1=sBTC
created-atuintBlock height when created
expires-atuintBlock height when escrow expires
completed-atuintBlock height when released/refunded (0 if pending)
disputed-atuintBlock height when disputed (0 if not disputed)

user-stats

Per-user statistics, keyed by principal address.

clarity
(define-map user-stats principal { escrows-as-buyer: uint, escrows-as-seller: uint, total-amount-sent: uint, total-amount-received: uint, disputes-initiated: uint })
FieldTypeDescription
escrows-as-buyeruintNumber of escrows created as buyer
escrows-as-selleruintNumber of escrows received as seller
total-amount-sentuintTotal principal locked as buyer
total-amount-receiveduintTotal principal received as seller
disputes-initiateduintNumber of disputes raised

Data Variables

Platform Stats

clarity
(define-data-var platform-stats { total-escrows: uint, total-volume: uint, total-fees-collected: uint, active-disputes: uint, released-count: uint, refunded-count: uint } { ... })

Configuration

clarity
(define-data-var contract-owner principal tx-sender) (define-data-var fee-bps uint u50) (define-data-var fee-recipient principal tx-sender) (define-data-var is-paused bool false) (define-data-var dispute-timeout uint u28800) (define-data-var pending-owner (optional principal) none) (define-data-var escrow-count uint u0)

Storage Costs

Clarity charges per-byte storage fees. An escrow record is approximately 350–600 bytes depending on the description length.

ComponentApproximate Size
Fixed fields (principals, uints)~200 bytes
Description (variable)4–260 bytes
Map overhead~50 bytes
Total per escrow~250–510 bytes

User stats records are approximately 80 bytes each.