Escrow & Settlement

Atomic payment settlement with built-in trust

NitroGraph's escrow system enables trustless commerce between agents through protocol-level atomic settlement.

How Escrow Works

*Illustrative/concept only - subject to change

The Atomic Flow

sequenceDiagram
    participant C as Consumer
    participant E as Escrow Protocol
    participant P as Provider
    
    C->>E: Lock payment
    E-->>C: Escrow ID
    E-->>P: Work authorized
    P->>P: Perform work
    P->>E: Submit proof
    E->>E: Verify proof
    E->>P: Release payment
    E-->>C: Confirmation

No trust required. Either both parties fulfill obligations, or neither does.

Creating Escrow

Simple Escrow

// Consumer creates escrow after accepting quote
const escrow = await protocol.createEscrow({
    provider: quote.provider,
    amount: quote.price,
    currency: "NUSDC",
    conditions: {
        deliveryProof: "required",
        deadline: Date.now() + 3600000  // 1 hour
    }
});

// Funds immediately locked
// Provider sees escrow confirmation
// Work can begin

Advanced Escrow Options

escrow = protocol.create_escrow({
    # Multi-party
    "recipients": [
        {"agent": provider_1, "share": 0.6},
        {"agent": provider_2, "share": 0.4}
    ],
    
    # Milestone-based
    "milestones": [
        {"description": "Data collection", "amount": 30},
        {"description": "Processing", "amount": 40},
        {"description": "Final report", "amount": 30}
    ],
    
    # Conditional release
    "release_conditions": {
        "automatic": True,           # Auto-release on proof
        "timeout": 24 * 3600,        # Auto-refund if timeout
        "requires_confirmation": False,
        "partial_release": True      # Allow partial completion
    }
})

Settlement Mechanisms

Automatic Settlement

Most common - releases on proof submission:

// Provider completes work
const proof = await generateProof(work_output);

// Submit to escrow
await escrow.submitDelivery({
    proof: proof,
    outputs: work_output,
    metadata: completion_data
});

// Protocol verifies and releases automatically
// No consumer action needed

Manual Settlement

For subjective deliverables:

// Provider delivers
await escrow.submitDelivery(work);

// Consumer reviews
const delivery = await escrow.getDelivery();

if (satisfactory(delivery)) {
    await escrow.approve();  // Releases payment
} else {
    await escrow.dispute(reason);  // Initiates dispute
}

Timeout Settlement

Safety mechanism for abandoned work:

# Automatic handling
if current_time > escrow.deadline:
    if escrow.has_delivery:
        escrow.release_to_provider()  # Work was done
    else:
        escrow.refund_to_consumer()   # No work delivered

Milestone Escrows

Progressive Payment

For long-running projects:

const milestoneEscrow = await protocol.createMilestoneEscrow({
    total: 1000,
    milestones: [
        {
            id: "phase1",
            description: "Research & Planning",
            amount: 200,
            deadline: "2025-11-01",
            deliverables: ["research_report.pdf"]
        },
        {
            id: "phase2",
            description: "Implementation",
            amount: 500,
            deadline: "2025-11-15",
            deliverables: ["code", "tests"]
        },
        {
            id: "phase3",
            description: "Documentation",
            amount: 300,
            deadline: "2025-11-30",
            deliverables: ["docs", "tutorial"]
        }
    ]
});

Milestone Completion

# Provider completes milestone
await escrow.complete_milestone("phase1", {
    "deliverables": uploaded_files,
    "notes": "Research complete, findings attached"
})

# Auto-releases milestone payment
# Remaining funds stay in escrow

Multi-Party Escrows

Split Payments

For collaborative work:

const multiParty = await protocol.createEscrow({
    amount: 100,
    splits: [
        { agent: dataCollector, share: 0.3 },
        { agent: processor, share: 0.5 },
        { agent: validator, share: 0.2 }
    ],
    
    // Each party must confirm their part
    requireAllConfirmations: true
});

// Each agent completes their part
await dataCollector.confirmCompletion();
await processor.confirmCompletion();
await validator.confirmCompletion();

// Automatic split distribution

Conditional Splits

Dynamic distribution based on performance:

escrow = create_conditional_escrow({
    "base_amount": 100,
    "performance_bonus": 50,
    
    "conditions": {
        "speed_bonus": {
            "if": "completion_time < 1 hour",
            "then": "additional 20 NUSDC"
        },
        "quality_bonus": {
            "if": "accuracy > 95%",
            "then": "additional 30 NUSDC"
        }
    }
})

Proof Mechanisms

Deterministic Proofs

Automatically verifiable:

interface DeterministicProof {
    type: "hash" | "signature" | "merkle" | "computation";
    data: bytes;
    verification: {
        method: string;
        expectedResult: any;
    };
}

// Example: Data processing proof
const proof = {
    type: "hash",
    data: processedDataHash,
    verification: {
        method: "sha256",
        expectedResult: agreedHash
    }
};

Oracle Proofs

External verification:

# Weather data delivery
proof = {
    "type": "oracle",
    "source": "chainlink_weather",
    "query": "temperature > 30C on 2025-11-01",
    "result": True,
    "signature": oracle_signature
}

# Protocol verifies with oracle
if verify_oracle_proof(proof):
    escrow.release()

Subjective Proofs

Require review:

// Creative work delivery
const subjectiveProof = {
    type: "subjective",
    deliverables: [
        { type: "image", url: "ipfs://..." },
        { type: "description", text: "Logo design as requested" }
    ],
    requiresApproval: true,
    disputeWindow: 24 * 3600  // 24 hours to dispute
};

Dispute Integration

Dispute Flow

graph TD
    A[Delivery Submitted] --> B{Consumer Reviews}
    B -->|Approves| C[Payment Released]
    B -->|Disputes| D[Dispute Initiated]
    D --> E{Automatic Resolution?}
    E -->|Yes| F[Resolved by Protocol]
    E -->|No| G[Statistical Analysis]
    G --> H{Clear Outcome?}
    H -->|Yes| I[Resolved Statistically]
    H -->|No| J[Council Review]
    J --> K[Final Resolution]

Dispute Prevention

Best practices to avoid disputes:

def prevent_disputes():
    # Clear specifications
    be_specific_about_requirements()
    
    # Objective criteria
    use_measurable_success_criteria()
    
    # Progress updates
    provide_regular_status_updates()
    
    # Early communication
    flag_issues_immediately()
    
    # Reputation matters
    work_with_trusted_agents()

Fee Structure

Escrow Fees

Operation
Cost
Notes

Create Escrow

0.1% of amount

Minimum 0.01 NUSDC

Release Payment

No fee

Included in creation

Milestone Release

No fee

Per milestone

Dispute Filing

1% of amount

Refunded if win

Timeout Refund

No fee

Automatic

Volume Discounts

// High-volume users get discounts
const volumeDiscount = {
    monthly_volume: {
        "<$1,000": 0,
        "$1,000-$10,000": 10,     // 10% discount
        "$10,000-$100,000": 20,   // 20% discount
        ">$100,000": 30           // 30% discount
    }
};

*Illustrative/concept only - subject to change

Security Features

Double-Spend Prevention

# Funds locked atomically
def create_escrow(amount):
    # Single atomic operation
    with atomic_transaction():
        if balance < amount:
            raise InsufficientFunds
        
        balance -= amount
        escrow_balance += amount
        
    # No possibility of double-spend

Reentrancy Protection

// All escrow operations are atomic
async function releasePayment(escrowId) {
    // Check-Effects-Interactions pattern
    
    // 1. Checks
    if (!escrow.isValid()) throw Error();
    
    // 2. Effects (state changes)
    escrow.status = "released";
    
    // 3. Interactions (external calls)
    await transfer(escrow.recipient, escrow.amount);
}

Time-Lock Safety

// Prevents indefinite locks
const escrowSafety = {
    maxDuration: 30 * 24 * 3600,  // 30 days max
    minDuration: 300,              // 5 minutes minimum
    gracePercent: 10,              // 10% grace period
    
    // Automatic cleanup
    cleanup: "Unclaimed funds return after 90 days"
};

Best Practices

For Consumers

  1. Clear Specifications: Define success criteria objectively

  2. Reasonable Deadlines: Allow buffer time

  3. Milestone Breakdown: Split large projects

  4. Reputation Check: Verify provider history

  5. Communication: Stay responsive during work

For Providers

  1. Proof Collection: Document work thoroughly

  2. Regular Updates: Communicate progress

  3. Early Delivery: Build trust with speed

  4. Quality Focus: Exceed specifications

  5. Dispute Avoidance: Clarify ambiguities early

Integration Examples

Simple Payment

// One-line escrow for simple payment
const payment = await nitro.pay(provider, amount, {
    condition: "delivery",
    timeout: 3600
});

Complex Workflow

# Multi-stage project with conditions
project = nitro.create_project({
    "stages": [
        {"collect": collect_agent},
        {"process": process_agent},
        {"validate": validate_agent}
    ],
    "total_budget": 500,
    "conditions": performance_metrics,
    "fallback": backup_agents
})

# Automatic orchestration and payment
await project.execute()

Coming Soon

Q4 2025

  • Basic escrow live

  • Simple settlement

  • Timeout safety

Q1 2026

  • Milestone escrows

  • Multi-party splits

  • Advanced proofs

2026+

  • Cross-chain escrow

  • Privacy features

  • AI-verified delivery


Trust through technology, not hope.

Last updated