Conditional Payment Smart Contract
A robust escrow system built on the Stacks blockchain using Clarity that enables secure conditional payments between parties with built-in dispute resolution.
This smart contract implements a trustless escrow service where payments are held until predefined conditions are met. It supports multi-party transactions with optional arbitration and automatic refunds for expired payments.
- Conditional Escrow: Funds locked until cryptographic proof of condition fulfillment
- Multi-Party Support: Payer, payee, and optional arbiter roles
- Timeout Protection: Automatic refunds after expiration
- Dispute Resolution: Arbiter-mediated conflict resolution
- Fee System: Configurable contract fees (default 0.5%)
- Security: Comprehensive input validation and access controls
(create-payment payee amount condition-hash timeout-blocks arbiter)
Creates a new conditional payment with specified terms. Funds are immediately escrowed.
(verify-condition payment-id proof-data)
Verifies that provided proof matches the original condition hash using SHA256.
(release-payment payment-id)
Releases escrowed funds to payee after conditions are verified. Deducts contract fee.
(refund-payment payment-id)
Returns funds to payer if payment expired or authorized by arbiter.
(dispute-payment payment-id)
Flags payment as disputed, requiring arbiter intervention.
- Create Payment: Payer creates payment with condition hash and timeout
- Verify Condition: Any authorized party submits proof data
- Release Payment: Once verified, funds transfer to payee minus fees
- Handle Disputes: Arbiter can resolve conflicts or force refunds
- Input Validation: All user inputs validated before processing
- Access Controls: Only authorized parties can perform actions
- Reentrancy Protection: State changes before external calls
- Principal Validation: Prevents invalid or self-referencing addresses
u100: Unauthorized accessu101: Payment not foundu103: Insufficient fundsu104: Payment expiredu106: Conditions not metu108: Invalid input parameters
Deploy using Clarinet or Stacks CLI. Set appropriate contract owner and initial fee structure before mainnet deployment.
This contract provides a secure foundation for conditional payments with comprehensive error handling and dispute resolution mechanisms built for production use.