> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paycrest.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Protocol Overview

> Deep dive into the Paycrest protocol architecture, participants, and core components

Paycrest is a decentralized payment routing protocol for stablecoin-fiat payments in emerging markets. It handles the full stack — order routing, encrypted message passing, onchain escrow, provider matching, and fiat execution — without ever custodying user funds. This page covers the core architecture, participants, and key technical components. For traction, roadmap, and competitive positioning, see the [Introduction](/introduction).

## Protocol Vision

Paycrest exists to be **the neutral routing layer for stablecoin-fiat payments** — open infrastructure that any application can integrate to offer on- and offramps without being locked into a single stablecoin issuer's ecosystem.

The key properties:

<CardGroup cols={2}>
  <Card title="Non-Custodial" icon="lock">
    Paycrest never holds user funds. Escrow is onchain, enforced by the Gateway contract.
  </Card>

  <Card title="Open & Composable" icon="puzzle-piece">
    Any smart contract can trigger settlement. Any app can integrate the Sender API.
  </Card>

  <Card title="Provider-Sovereign" icon="building">
    Liquidity providers run their own nodes, set their own rates, and connect their own PSPs.
  </Card>

  <Card title="Compliance at the Edges" icon="shield-check">
    Providers own local regulatory obligations; senders own theirs. The protocol coordinates requirement exchange — not centralized compliance vetting.
  </Card>
</CardGroup>

## Core Architecture

The Paycrest protocol consists of several key components working together:

### 1. Gateway Smart Contract

The core multi-chain contract deployed on fast EVM-compatible networks (e.g., Base, Arbitrum, Lisk). It manages:

* **Order creation** and validation
* **Token escrow** and conditional settlement
* **Fee distribution** and protocol governance
* **Multi-chain interoperability**

### 2. Paycrest Node

The unified protocol client that can operate in three modes:

<CardGroup cols={3}>
  <Card title="Aggregator Mode">
    * Listens to onchain payment order events
    * Indexes registered Providers
    * Performs matching logic
    * Validates KYC data offchain
    * Issues onchain attestations
  </Card>

  <Card title="Provision Mode">
    * Registers liquidity parameters
    * Monitors order matching
    * Integrates with Payment Service Providers (PSPs)
    * Performs last-mile fiat delivery
    * Submits fulfillment proofs
  </Card>

  <Card title="Hybrid Mode">
    * Operates as both Aggregator and Provider
    * Useful for participants with both capabilities
    * Optimizes for participants with full-stack operations
  </Card>
</CardGroup>

### 3. Sender API & Webhooks

Interfaces that allow businesses and apps to:

* **Create payment orders** with operational settings
* **Configure refund addresses**, fee addresses, and fee percentages
* **Manage API keys** and authentication
* **Receive real-time updates** on status transitions
* **Handle webhook notifications** for order lifecycle events

### 4. KYC Attestation Registry

A registry of attestations for both Senders and Providers:

* **Onchain attestations** for identity verification
* **Offchain verifiable credentials** support
* **Encrypted KYC data** stored on decentralized storage
* **Compliance integration** with regulatory requirements

## Protocol Participants

### Sender

A KYB-verified entity that initiates either a fiat-to-stablecoin or stablecoin-to-fiat transaction. This can be:

* **Smart contracts** or dApps
* **API clients** integrating with the protocol
* **Smart accounts** (e.g., EIP-7702) for advanced wallet functionality
* **Traditional applications** abstracting away blockchain complexity

The sender supplies the recipient's fiat account information and initiates the payment order.

### Recipient

The beneficiary of the transaction who receives:

* **Local fiat** in a bank account or mobile wallet
* **Stablecoins** in a crypto wallet

The recipient doesn't need to interact with the protocol directly - they simply receive the funds through their preferred method.

### Provider

A KYB-verified participant that supplies fiat liquidity in exchange for stablecoins or provides stablecoins in exchange for fiat. Providers:

* **Connect to the aggregator** and register rates and limits
* **Fulfill payment orders** (off-ramp or on-ramp)
* **Receive corresponding assets** post-validation
* **Integrate with Payment Service Providers (PSPs)** for last-mile delivery

### Aggregator

A KYB-verified entity that coordinates the entire order routing process:

* **Listens to payment order events** from the Gateway contract
* **Matches orders** with suitable Providers
* **Coordinates fulfillment** and settlement
* **Performs offchain KYB verification** for both Senders and Providers
* **Splits large orders** across multiple Providers
* **Issues onchain attestations** for compliance
* **Enforces penalties** for failed delivery

## Order Lifecycle

<Steps>
  <Step title="Order Creation">
    Sender creates a payment order on the Gateway contract with recipient details, amount, and rate.
  </Step>

  <Step title="Aggregation">
    Aggregator indexes the order and matches it with suitable Providers based on rates, limits, and availability.
  </Step>

  <Step title="Provider Assignment">
    One or more Providers are assigned to fulfill the order, with the order potentially split across multiple Providers.
  </Step>

  <Step title="Fulfillment">
    Providers execute the payment:

    <ul>
      <li><b>Offramp:</b> Provider delivers fiat to the recipient via PSP integration.</li>
      <li><b>Onramp:</b> Provider receives fiat from the sender via local payment rails.</li>
    </ul>
  </Step>

  <Step title="Validation">
    <ul>
      <li><b>Offramp:</b> Provision node validates fulfillment by checking the status of the fiat transfer via PSP APIs.</li>
      <li><b>Onramp:</b> Aggregator validates fulfillment by confirming the onchain stablecoin transfer to the recipient.</li>
    </ul>
  </Step>

  <Step title="Settlement">
    <ul>
      <li><b>Offramp:</b> Smart contract releases escrowed stablecoins to the provider after successful validation.</li>
      <li><b>Onramp:</b> Fulfillment, validation, and settlement occur in one step: after the provision node confirms fiat receipt, the stablecoins are released onchain to the recipient.</li>
    </ul>
  </Step>

  <Step title="Refund">
    If the order cannot be fulfilled, funds are automatically refunded to the sender. No manual dispute process is required.
  </Step>
</Steps>

<Callout type="info">
  <b>Offramp:</b> Fulfillment = Provider delivers fiat to recipient. Validation = Provision node checks fiat transfer status via PSP API. Settlement = Escrowed stablecoins released to provider.

  <b>Onramp:</b> Fulfillment = Provider receives fiat from sender. Validation = Aggregator confirms onchain stablecoin transfer to recipient. Settlement = All three steps happen atomically after fiat receipt is confirmed.
</Callout>

## Multi-Chain Support

Paycrest is live on **8 EVM-compatible networks**:

* **Ethereum**
* **Base**
* **Polygon**
* **BNB Smart Chain**
* **Arbitrum One**
* **Lisk**
* **Celo**
* **Scroll**

Additional networks (Starknet, Tron, Asset Chain, Optimism) have Gateway contracts deployed but aggregator support is pending. See [Gateway Contract Addresses](/resources/gateway-contract-addresses) for the full deployment table.

## Security & Compliance

### Smart Contract Security

* **Audited Gateway contracts** with escrow functionality
* **Multi-signature governance** for protocol upgrades
* **Timelock mechanisms** for critical parameter changes
* **Emergency pause functionality** for security incidents

### Compliance Integration

* **KYB verification** for all participants
* **Identity attestation registry** onchain
* **Regulatory reporting** capabilities
* **AML/CFT compliance** through integrated providers

### Privacy Protection

* **Encrypted recipient data** stored offchain
* **Minimal data retention**: only what is necessary for order routing and settlement

## Fee Structure

The Paycrest protocol implements a **zero-fee experience for senders**:

* **Sender fees**: Optional fees that sender businesses can charge to their users
* **Provider fees**: Competitive rates based on market conditions
* **Protocol fees**: Fees paid to aggregators for order routing and coordination
* **Network fees**: Gas costs for blockchain transactions

Providers earn fees by:

* **Bid-ask spreads** on currency pairs
* **Volume-based incentives** for high-frequency providers
* **Quality bonuses** for reliable fulfillment
* **Geographic premiums** for underserved markets

<Note>
  **Current fee model**: Paycrest currently operates the sole aggregator (federated model). The 0.5% aggregator fee on each settled order flows to Paycrest. This will transition to a competitive multi-aggregator model in a future protocol phase.
</Note>

### Delivery Methods

* **Bank Transfer**: Direct deposit to local bank account
* **Mobile**: Transfer to mobile wallet (M-Pesa, etc.) or mobile payment systems (UPI, PIX)
* **Crypto Wallet**: Receive stablecoins in specified wallet

<Callout type="warning">Cash pickup is not supported. All off-ramps are to fiat accounts or wallets.</Callout>

## Governance

### Early Stage

In early stages, protocol changes are ratified by a **Paycrest Core Multisig**:

* **Founding contributors** and technical leads
* **Multi-signature requirements** for all changes
* **Transparent proposal process** with community input
* **Emergency procedures** for critical updates

### Future Decentralization

As the protocol matures, governance will transition to:

* **Community-led structure** with token-weighted voting
* **Delegate-based technical councils** for specialized decisions
* **Onchain governance** for parameter changes
* **Offchain coordination** for complex upgrades

## Technical Specifications

### Smart Contracts

* **Gateway Contract**: Core order management and escrow
* **Token Contracts**: Standard ERC-20 implementations
* **Governance Contracts**: Multi-signature and timelock mechanisms
* **Attestation Registry**: KYC and compliance verification

### API Standards

* **RESTful API** for all interactions
* **Webhook integration** for real-time event notifications
* **Rate limiting** and authentication

### Network Requirements

* **High availability** aggregator nodes
* **Low latency** blockchain connections
* **Redundant infrastructure** for reliability
* **Geographic distribution** for global access

### Dispute Resolution

If an order is not fulfilled, it is automatically refunded. The aggregator does not handle disputes directly. If an order is stuck, communication between senders and providers may occur via a decentralized messaging protocol (e.g., XMTP).

### Integration Options

Senders can create orders via:

* The Sender API (recommended for most users)
* Direct contract interaction (for advanced/offramp use cases)

<Note>
  The Paycrest protocol is designed to be both Web3-native and accessible to traditional financial applications. The modular architecture allows for different deployment models while maintaining the core benefits of decentralization.
</Note>
