Skip to main content

ProtocolViewer Contract

The ProtocolViewer is a utility contract that provides convenient view functions to query deposit and intent data from the Escrow and Orchestrator contracts. It aggregates data from multiple contracts into structured views.

Overview

  • Contract: ProtocolViewer.sol
  • Inherits: IProtocolViewer
  • Purpose: Aggregates and provides structured views of deposits and intents

Key State Variables

IEscrow
required
Immutable reference to the Escrow contract
IOrchestrator
required
Immutable reference to the Orchestrator contract

Constructor

address
required
Address of the Escrow contract
address
required
Address of the Orchestrator contract

View Functions

getDeposit

Gets details for a single deposit including payment methods, currencies, and available liquidity.
uint256
The ID of the deposit
uint256
The deposit ID
IEscrow.Deposit
The core deposit struct from Escrow
uint256
Total available liquidity (remainingDeposits + reclaimable from expired intents)
PaymentMethodDataView[]
Array of payment method configurations including:
  • paymentMethod: Payment method identifier
  • verificationData: Payment verification data
  • currencies: Array of supported currencies with min conversion rates
bytes32[]
Array of active intent hashes for this deposit
Example:

getDepositFromIds

Gets deposit details for a list of deposit IDs.
uint256[]
Array of deposit IDs
Example:

getIntent

Gets details for a single intent including the associated deposit.
bytes32
The hash of the intent
bytes32
The intent hash
IOrchestrator.Intent
The intent struct from Orchestrator containing:
  • owner: Intent owner address
  • to: Recipient address
  • escrow: Escrow contract address
  • depositId: Associated deposit ID
  • amount: Intent amount
  • paymentMethod: Payment method identifier
  • fiatCurrency: Fiat currency code
  • conversionRate: Conversion rate
  • payeeId: Payee identifier
  • timestamp: Creation timestamp
  • referrer: Referrer address
  • referrerFee: Referrer fee amount
  • postIntentHook: Post-intent hook address
  • data: Additional hook data
DepositView
Full deposit view for the deposit associated with this intent
Example:

getIntents

Gets details for a list of intent hashes.
bytes32[]
Array of intent hashes
Example:

getAccountIntents

Gets the active intents for a specific account.
address
The account address
Example:

Data Structures

DepositView

PaymentMethodDataView

IntentView

Use Cases

Frontend Integration

The ProtocolViewer is ideal for frontend applications to:
  1. Display deposit listings with all payment methods and available liquidity
  2. Show intent details with full context about the underlying deposit
  3. Track user activity by fetching all active intents for an account
  4. Batch data fetching to reduce RPC calls

Example: Building a Deposit Explorer

Example: User Dashboard

Best Practices

  1. Batch Queries: Use getDepositFromIds and getIntents to fetch multiple records in a single call
  2. Check Availability: Always check availableLiquidity and acceptingIntents before allowing users to signal intents
  3. Cache Results: The view functions are read-only, so results can be cached for a short period to reduce RPC load
  4. Gas Optimization: For very large arrays, consider implementing pagination on your frontend