# Relayer

### TL;DR

* In return for a fee, Relayers will provide an optional service to Protocol users — adding to the privacy set
* Relayers pass bundles of transactions, signed and paid, to the Shielded Pool contract

### Introduction

Panther Relayers are [specialist Operators](#service-providers) providing a relaying and bundling service that runs the (optional) Relayer service to provide an additional privacy layer by breaking the link between the initiator of the transaction and the transaction itself. Relayers earn rewards for:

* signing the transactions with their public key
* paying the gas fees
* relaying bundles of transactions to the Shielded Pool contract

Relayers, therefore, enhance privacy, since observers are unable to pinpoint the actual address that initiated the transaction because the Relayer signs the underlying blockchain transaction with their key.

### Supported transactions

As of testnet stage 6, Relayers support:

* Account activation
* Account renewal
* Claiming PRP voucher
* Deposit
* Internal transfer
* PRP to ZKP exchange
* Withdrawal

> This same feature set is intended for mainnet beta release

### Overview

The Relayer service leverages features introduced by the [ERC-4337 standard](https://eips.ethereum.org/EIPS/eip-4337), such as tx (transaction) bundling and account abstraction.

{% @mermaid/diagram content="sequenceDiagram
participant dApp
participant Relayer service
participant PayMaster
participant Uniswap v3
participant Panther contracts
participant Relayer Account
participant Relayer EOA

```
dApp->Relayer service: Relayer/tx request
Relayer service->Relayer service: Bundles several tx requests
Relayer service->PayMaster: Bundled tx details
PayMaster->PayMaster: Calculates fee in zZKP (gas fees + zMiner fees) + failure fee)
PayMaster->PayMaster: Verifies fee covers cost in native token
alt verification success 
    PayMaster->Relayer service: Confirmation
else verification failure
    PayMaster->Relayer service: Denial, fail flow intitated
end
PayMaster->Uniswap v3: Convert fee amount ZKP>native token
Relayer service->Panther contracts: Submits tx bundle for execution, signs txs, and pays gas fees
Panther contracts->PayMaster: Pays Relayer Operator
alt tx success 
    PayMaster->Relayer Account: Payout gas fees (in native token)
else tx failure
    PayMaster->Relayer Account: Payout gas fees (in native token)
end
Relayer Account->Relayer EOA: Claims fee" %}
```

Relayers pickup transaction relay requests and bundle these together. The details of this bundle are passed to the PayMaster contract which verifies the fee calculation.

> Note, PayMaster does this at intervals, not per bundle, to reduce fees.

### Fees

Note that the fee calculation includes a buffer value, the failure fee. This ensures that the pool controlled by the PayMaster does not become depleted in the event of tx failures due to a re-org, gas-cost spike, or other impediment to tx success.

The gas fees are those fees charged by the blockchain, so Matic is required to pay tx costs in testnet up to Stage 5.

The [zMiner](https://github.com/pantherprotocol/panther-protocol-doc/blob/main/ecosystem-operators/relayer/zMiner/README.md) fee pays the [Ecosystem Operator](https://docs.pantherprotocol.io/docs/ecosystem/ecosystem-operators) that computes how to mine the transactions on-chain.

### Rewards

The gas fee charged by the Relayers includes their fee.

### Service providers

Panther has integrated with Etherspot’s Skandha ERC4337 Relayer and Bundler service to send transactions to the blockchain. Users may select (Bundler = YES / NO) before submitting their transactions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pantherprotocol.io/docs/ecosystem/ecosystem-operators/relayer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
