TribFi Protocol Documentation • Base Mainnet

TribFi Protocol Whitepaper

The decentralized architecture for fair-launch community tokens, zero-rug locked liquidity, and lifetime creator rewards on Base. Built with fixed 1 Billion token supplies, 5% anti-snipe limits, and permanent non-custodial smart contracts.

Section 09 • DeFi & Staking Utilities
~6 min read•9 of 20

Marketplace & Creator Shops: Multi-Token Escrow & Buyer Protection

Non-custodial smart contract escrow, 72h auto-release, dispute resolution, and pull payouts

1. Escrow State Machine & Lifecycle

TribFi empowers creators and communities to launch decentralized digital storefronts powered by MarketplaceEscrow.sol. Shops support payments in native ETH (address(0)) and any ERC-20 token, including community tribe tokens.

Orders progress deterministically through 6 states: None (0), Funded (1), Delivered (2), Completed (3), Disputed (4), and Refunded (5).

2. Gas-Optimized Struct Packing (6 Slots)

The EscrowOrder struct packs critical fields into just 6 EVM storage slots (down from 10 slots in legacy contracts), saving ~80,000 gas per order creation:

// MarketplaceEscrow.sol - Packed Storage Layout
struct EscrowOrder {
    bytes32 orderId;           // Slot 1 (32 bytes)
    address buyer;             // Slot 2 (20 bytes)
    EscrowState state;         // Slot 2 (1 byte)
    bool autoReleased;         // Slot 2 (1 byte)
    uint16 feeBps;             // Slot 2 (2 bytes) -> Total 24 bytes packed
    address seller;            // Slot 3 (20 bytes)
    address token;             // Slot 4 (20 bytes)
    uint256 amount;            // Slot 5 (32 bytes)
    uint40 createdAt;          // Slot 6 (5 bytes)
    uint40 deliveredAt;        // Slot 6 (5 bytes) -> Total 10 bytes packed
}

3. Anti-Frivolous Dispute Windows

  • 72-Hour Auto-Release: If a buyer does not confirm or dispute an order within 72 hours of delivery, the seller can trigger autoRelease() to claim payment.
  • 4-Hour Minimum Wait: Buyers must wait at least 4 hours after delivery before filing a dispute, preventing instant griefing.
  • 14-Day Expiration: If a seller fails to deliver within 14 days, the buyer can safely reclaim 100% of their funds.
  • Fair Refund: When an order is refunded to the buyer, 0% protocol commission is charged.

4. DoS-Resistant Pull Payouts

All proceeds are credited to pendingWithdrawals[recipient][token]. Sellers and buyers pull their payouts non-custodially, guaranteeing that state transitions never revert due to malicious receiver contracts.