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
Immutable reference to the Escrow contract
Immutable reference to the Orchestrator contract
Constructor
Address of the Escrow contract
Address of the Orchestrator contract
View Functions
getDeposit
Gets details for a single deposit including payment methods, currencies, and available liquidity.The ID of the deposit
The deposit ID
The core deposit struct from Escrow
Total available liquidity (remainingDeposits + reclaimable from expired intents)
Array of payment method configurations including:
paymentMethod: Payment method identifierverificationData: Payment verification datacurrencies: Array of supported currencies with min conversion rates
Array of active intent hashes for this deposit
getDepositFromIds
Gets deposit details for a list of deposit IDs.Array of deposit IDs
getIntent
Gets details for a single intent including the associated deposit.The hash of the intent
The intent hash
The intent struct from Orchestrator containing:
owner: Intent owner addressto: Recipient addressescrow: Escrow contract addressdepositId: Associated deposit IDamount: Intent amountpaymentMethod: Payment method identifierfiatCurrency: Fiat currency codeconversionRate: Conversion ratepayeeId: Payee identifiertimestamp: Creation timestampreferrer: Referrer addressreferrerFee: Referrer fee amountpostIntentHook: Post-intent hook addressdata: Additional hook data
Full deposit view for the deposit associated with this intent
getIntents
Gets details for a list of intent hashes.Array of intent hashes
getAccountIntents
Gets the active intents for a specific account.The account address
Data Structures
DepositView
PaymentMethodDataView
IntentView
Use Cases
Frontend Integration
The ProtocolViewer is ideal for frontend applications to:- Display deposit listings with all payment methods and available liquidity
- Show intent details with full context about the underlying deposit
- Track user activity by fetching all active intents for an account
- Batch data fetching to reduce RPC calls
Example: Building a Deposit Explorer
Example: User Dashboard
Best Practices
- Batch Queries: Use
getDepositFromIdsandgetIntentsto fetch multiple records in a single call - Check Availability: Always check
availableLiquidityandacceptingIntentsbefore allowing users to signal intents - Cache Results: The view functions are read-only, so results can be cached for a short period to reduce RPC load
- Gas Optimization: For very large arrays, consider implementing pagination on your frontend