Smart Contract Overview

The sBTC Escrow smart contract (escrow-v6.clar) is a Clarity v4 contract deployed on the Stacks blockchain. It serves as the trustless, on-chain core of the escrow protocol.

Contract Identity

PropertyValue
Nameescrow-v6
LanguageClarity v4
TestnetST1HK6H018TMMZ1BZPS1QMJZE9WPA7B93T8ZHV94N.escrow-v6
MainnetTBD

Constants

Status Codes

ConstantValueMeaning
STATUS_PENDINGu0Escrow created, funds locked
STATUS_RELEASEDu1Funds sent to seller
STATUS_REFUNDEDu2Funds returned to buyer
STATUS_DISPUTEDu3Frozen, awaiting resolution

Token Types

ConstantValueToken
TOKEN_STXu0Native STX
TOKEN_SBTCu1sBTC (SIP-010)

Limits

ConstantValueDescription
MAX_FEE_BPSu500Max fee 5%
MAX_DURATIONu350400~365 days in blocks
MIN_STX_AMOUNTu10000.001 STX
MAX_STX_AMOUNTu100000000000000100M STX
MIN_SBTC_AMOUNTu100000.0001 BTC
MAX_SBTC_AMOUNTu10000000000100 BTC

Error Codes

RangeCategory
1000–1999Authorization errors
2000–2999Escrow state errors
3000–3999Transfer errors

Function Index

Public Functions (User)

FunctionDescription
create-escrowCreate a new escrow with funds
releaseRelease funds to seller
refundRefund funds to buyer
disputeRaise a dispute
extend-escrowExtend escrow deadline

Public Functions (Admin)

FunctionDescription
resolve-dispute-for-buyerResolve dispute in buyer's favor
resolve-dispute-for-sellerResolve dispute in seller's favor
resolve-expired-disputeBuyer self-recovery after timeout
set-pausedPause/unpause contract
set-fee-bpsUpdate platform fee
set-fee-recipientUpdate fee recipient address
set-dispute-timeoutUpdate dispute timeout period
set-pending-ownerInitiate ownership transfer
confirm-ownerAccept ownership transfer

Read-Only Functions

FunctionDescription
get-escrowGet escrow details by ID
get-escrow-countTotal number of escrows
get-user-statsUser's escrow statistics
get-platform-statsPlatform-wide statistics
get-configCurrent contract configuration
calculate-feeCalculate fee for an amount
is-expiredCheck if an escrow has expired