> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zkp2p/zkp2p-contracts/llms.txt
> Use this file to discover all available pages before exploring further.

# PaymentVerifierRegistry

> Registry for managing payment methods, verifiers, and supported currencies

## Overview

The `PaymentVerifierRegistry` is a central registry contract that manages the configuration of supported payment methods, their associated verifier contracts, and the currencies each payment method supports. It provides a flexible system for adding and managing different payment methods (like Venmo, Revolut, etc.) along with their specific verification logic.

**Contract Location:** `contracts/registries/PaymentVerifierRegistry.sol`

## Purpose

The PaymentVerifierRegistry serves several critical functions:

* **Payment Method Management**: Register and manage different off-chain payment methods
* **Verifier Assignment**: Associate each payment method with its specific verifier contract
* **Currency Support**: Define which currencies (USD, EUR, etc.) each payment method supports
* **Centralized Configuration**: Provide a single source of truth for payment method configurations

## Key Components

### State Variables

```solidity theme={null}
mapping(bytes32 => PaymentMethodConfig) public store;
bytes32[] public paymentMethods;
```

* `store`: Maps payment method hashes to their configuration (verifier address and supported currencies)
* `paymentMethods`: Array of all registered payment method identifiers

### PaymentMethodConfig Struct

```solidity theme={null}
struct PaymentMethodConfig {
    bool initialized;
    address verifier;
    mapping(bytes32 => bool) isCurrency;
    bytes32[] currencies;
}
```

Stores the complete configuration for a payment method including its verifier contract and supported currencies.

## Core Functions

### Adding a Payment Method

```solidity theme={null}
function addPaymentMethod(
    bytes32 _paymentMethod,
    address _verifier,
    bytes32[] calldata _currencies
) external onlyOwner
```

Registers a new payment method with its verifier and initial set of supported currencies.

**Parameters:**

* `_paymentMethod`: Hash of the payment method name (lowercase, e.g., `keccak256("venmo")`)
* `_verifier`: Address of the verifier contract for this payment method
* `_currencies`: Array of currency code hashes (e.g., `keccak256("USD")`)

**Requirements:**

* Payment method must not already exist
* Verifier address cannot be zero
* At least one currency must be provided

**Emits:** `PaymentMethodAdded(bytes32 indexed paymentMethod)`

**Reference:** `contracts/registries/PaymentVerifierRegistry.sol:44`

### Removing a Payment Method

```solidity theme={null}
function removePaymentMethod(bytes32 _paymentMethod) external onlyOwner
```

Removes a payment method and all its associated configuration.

**Reference:** `contracts/registries/PaymentVerifierRegistry.sol:68`

### Managing Currencies

```solidity theme={null}
function addCurrencies(bytes32 _paymentMethod, bytes32[] calldata _currencies) public onlyOwner
function removeCurrencies(bytes32 _paymentMethod, bytes32[] calldata _currencies) external onlyOwner
```

Add or remove supported currencies for a specific payment method.

**Reference:** `contracts/registries/PaymentVerifierRegistry.sol:88` and `:102`

## View Functions

### Query Payment Methods

```solidity theme={null}
function isPaymentMethod(bytes32 _paymentMethod) external view returns (bool)
function getPaymentMethods() external view returns (bytes32[] memory)
function getVerifier(bytes32 _paymentMethod) external view returns (address)
```

Query registered payment methods and their verifiers.

### Query Currencies

```solidity theme={null}
function isCurrency(bytes32 _paymentMethod, bytes32 _currencyCode) external view returns (bool)
function getCurrencies(bytes32 _paymentMethod) external view returns (bytes32[] memory)
```

Check currency support for specific payment methods.

## Integration with Core Contracts

### Orchestrator

The Orchestrator contracts (`Orchestrator.sol` and `OrchestratorV2.sol`) reference the PaymentVerifierRegistry to:

* Validate that intents use registered payment methods
* Retrieve the appropriate verifier contract for payment verification
* Ensure the requested currency is supported by the payment method

**Reference:** `contracts/Orchestrator.sol:83`

### EscrowV2

EscrowV2 uses the registry to validate payment method configurations when creating deposits.

**Reference:** `contracts/EscrowV2.sol:128`

### Payment Verifiers

Verifier contracts registered in this registry are called to validate ZK proofs of off-chain payments.

## Access Control

### Owner-Only Functions

All state-modifying functions are restricted to the contract owner:

* `addPaymentMethod()`
* `removePaymentMethod()`
* `addCurrencies()`
* `removeCurrencies()`

**Access Control Pattern:** OpenZeppelin's `Ownable` with `onlyOwner` modifier

### View Functions

All view functions are publicly accessible, allowing any contract or user to query payment method configurations.

## Events

```solidity theme={null}
event PaymentMethodAdded(bytes32 indexed paymentMethod);
event PaymentMethodRemoved(bytes32 indexed paymentMethod);
event CurrencyAdded(bytes32 indexed paymentMethod, bytes32 indexed currencyCode);
event CurrencyRemoved(bytes32 indexed paymentMethod, bytes32 indexed currencyCode);
```

These events enable off-chain monitoring of payment method configuration changes.

## Usage Example

Adding a new payment method:

```solidity theme={null}
// Calculate payment method and currency hashes
bytes32 venmoHash = keccak256("venmo");
bytes32[] memory currencies = new bytes32[](2);
currencies[0] = keccak256("USD");
currencies[1] = keccak256("EUR");

// Add payment method with verifier address
paymentVerifierRegistry.addPaymentMethod(
    venmoHash,
    venmoVerifierAddress,
    currencies
);
```

## Security Considerations

1. **Owner Control**: Only the owner can modify payment method configurations, providing strong governance over supported payment methods
2. **Validation**: All inputs are validated to prevent zero addresses and duplicate entries
3. **Immutable After Addition**: Payment method verifiers cannot be changed after addition (must remove and re-add)
4. **Hash-Based Identification**: Using hashes instead of strings provides gas efficiency and standardization

## Related Contracts

* [Orchestrator](/contracts/orchestrator) - Uses registry to validate payment methods
* [EscrowV2](/contracts/escrow) - References registry for deposit creation
* Payment Verifiers - Contracts registered in this registry for proof verification
