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

# Solana-Prioritätsgebührenschätzung: Account Keys Methode

> Schätzen Sie Solana-Prioritätsgebühren mit Account Keys über die Helius Priority Fee API. Schnelle Gebührenschätzungen für prä-transaktionale Analysen und Batch-Operationen.

<Info>
  **Erweiterte Methode**: Holen Sie Prioritätsgebührenschätzungen mithilfe von Account Keys für spezialisierte Anwendungsfälle wie prä-transaktionale Analysen, Batch-Operationen und Account-Pattern-Forschung ein.
</Info>

## Übersicht

Die Account Keys Methode bietet eine einfachere Alternative zur Transaktionsserialisierung, wenn Sie schnelle Gebührenschätzungen benötigen oder Gebühren schätzen möchten, bevor Sie die vollständige Transaktion konstruieren.

<CardGroup cols={2}>
  <Card title="Erweiterte Anwendungsfälle" icon="key">
    * Prä-transaktionale Analyse
    * Batch-Account-Operationen
    * Marktforschung und Muster
    * Spezialisierte Architekturen
  </Card>

  <Card title="Kompromisse" icon="scale-unbalanced-flip">
    * Weniger genau als serialisierte Transaktionen
    * Keine anweisungsspezifische Analyse
    * Am besten für Account-Level-Muster
  </Card>
</CardGroup>

<Warning>
  **Empfehlung**: Für die meisten Anwendungen verwenden Sie stattdessen die [serialisierte Transaktionsmethode](/docs/de/priority-fee/estimating-fees-using-serialized-transaction). Diese Account Keys Methode ist für spezialisierte Anwendungsfälle gedacht, bei denen Sie eine Account-Level-Analyse oder prä-transactionale Planung benötigen.
</Warning>

## Wann Account Keys verwenden

<Tabs>
  <Tab title="Ideale Anwendungsfälle">
    <CardGroup cols={2}>
      <Card title="Prä-transaktionale Planung" icon="calendar">
        Holen Sie Gebührenschätzungen ein, bevor Sie vollständige Transaktionen konstruieren
      </Card>

      <Card title="Vereinfachte Integration" icon="puzzle-piece">
        Wenn Ihre Architektur die Transaktionsserialisierung erschwert
      </Card>

      <Card title="Schnelle Marktanalyse" icon="chart-line">
        Analysieren Sie Gebührenmuster für spezifische Konten, ohne Transaktionen zu erstellen
      </Card>

      <Card title="Multi-Account-Analyse" icon="users">
        Verstehen Sie Gebührenmuster über mehrere Konten unabhängig
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Spezialisierte Szenarien">
    **Forschung & Analyse**: Beim Studium von Gebührenmustern über verschiedene Konten und Programme

    **Batch-Operationen**: Beim Analysieren von Gebührenmustern über viele Konten gleichzeitig

    **Vorplanung**: Zur Kostenschätzung vor dem Aufbau komplexer Transaktions-Workflows

    **Benutzerdefinierte Architekturen**: Wenn Systembeschränkungen die Transaktionsserialisierung verhindern
  </Tab>
</Tabs>

## Schnellstart

<Steps>
  <Step title="Konten identifizieren">
    Bestimmen Sie, welche Konten an Ihrer Transaktion beteiligt sein werden
  </Step>

  <Step title="Die API aufrufen">
    Machen Sie eine Anfrage mit den Account Keys und dem gewünschten Prioritätslevel
  </Step>

  <Step title="Die Gebühr anwenden">
    Verwenden Sie die Schätzung, um die Prioritätsgebühr in Ihrer Transaktion festzulegen
  </Step>
</Steps>

### Einfaches Beispiel

<CodeGroup>
  ```javascript JavaScript theme={"system"}
  import { ComputeBudgetProgram } from "@solana/web3.js";

  // 1. Identify accounts involved in your transaction
  const accountKeys = [
    "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // Token program
    "YOUR_WALLET_ADDRESS",                          // Your wallet
    "RECIPIENT_ADDRESS"                             // Recipient
  ];

  // 2. Get priority fee estimate
  const priorityFee = await getPriorityFeeEstimate(connection, accountKeys, "Medium");

  // 3. Add to your transaction
  const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: priorityFee
  });
  transaction.add(priorityFeeIx);
  ```

  ```python Python theme={"system"}
  import requests

  # Get priority fee estimate
  def get_priority_fee_estimate(account_keys, priority_level="Medium"):
      response = requests.post(
          "https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY",
          json={
              "jsonrpc": "2.0",
              "id": "1",
              "method": "getPriorityFeeEstimate",
              "params": [{
                  "accountKeys": account_keys,
                  "options": {
                      "priorityLevel": priority_level,
                      "recommended": True
                  }
              }]
          }
      )
      return response.json()["result"]["priorityFeeEstimate"]

  # Usage
  accounts = ["ACCOUNT_1", "ACCOUNT_2", "ACCOUNT_3"]
  fee = get_priority_fee_estimate(accounts, "High")
  print(f"Priority fee: {fee} micro-lamports")
  ```
</CodeGroup>

## Implementierungsleitfaden

### Kernfunktion

Hier ist eine wiederverwendbare Funktion zur Ermittlung von Prioritätsgebührenschätzungen:

```javascript theme={"system"}
async function getPriorityFeeEstimate(connection, accountKeys, priorityLevel = "Medium") {
  const response = await fetch(connection.rpcEndpoint, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: "1",
      method: "getPriorityFeeEstimate",
      params: [{
        accountKeys: accountKeys,
        options: { 
          priorityLevel: priorityLevel,
          recommended: true 
        }
      }]
    })
  });
  
  const result = await response.json();
  
  if (result.error) {
    throw new Error(`Fee estimation failed: ${JSON.stringify(result.error)}`);
  }
  
  return result.result.priorityFeeEstimate;
}
```

### Vollständiges Beispiel mit mehreren Prioritätslevels

<Accordion title="Erweiterung zur vollständigen Implementierung anzeigen">
  ```javascript theme={"system"}
  const { 
    Connection, 
    PublicKey, 
    Transaction, 
    ComputeBudgetProgram 
  } = require("@solana/web3.js");

  // Initialize connection
  const connection = new Connection("https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY");

  async function analyzeAccountPriorityFees() {
    // Define accounts involved in your transaction
    const accountKeys = [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // Token program
      "YOUR_WALLET_ADDRESS",                          // Your wallet
      "TOKEN_ACCOUNT_ADDRESS",                        // Token account
      "RECIPIENT_ADDRESS"                             // Recipient
    ];
    
    try {
      // Get estimates for different priority levels
      const [lowFee, mediumFee, highFee, veryHighFee] = await Promise.all([
        getPriorityFeeEstimate(connection, accountKeys, "Low"),
        getPriorityFeeEstimate(connection, accountKeys, "Medium"), 
        getPriorityFeeEstimate(connection, accountKeys, "High"),
        getPriorityFeeEstimate(connection, accountKeys, "VeryHigh")
      ]);
      
      console.log("Priority Fee Estimates:");
      console.log(`Low:      ${lowFee} micro-lamports`);
      console.log(`Medium:   ${mediumFee} micro-lamports`);
      console.log(`High:     ${highFee} micro-lamports`);
      console.log(`VeryHigh: ${veryHighFee} micro-lamports`);
      
      // Get all levels at once for comparison
      const allLevels = await getAllPriorityLevels(connection, accountKeys);
      console.log("\nAll priority levels:", allLevels);
      
      return {
        low: lowFee,
        medium: mediumFee,
        high: highFee,
        veryHigh: veryHighFee,
        allLevels
      };
    } catch (error) {
      console.error("Error getting priority fees:", error);
      throw error;
    }
  }

  // Helper function to get all priority levels
  async function getAllPriorityLevels(connection, accountKeys) {
    const response = await fetch(connection.rpcEndpoint, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        jsonrpc: "2.0",
        id: "1",
        method: "getPriorityFeeEstimate",
        params: [{
          accountKeys: accountKeys,
          options: { 
            includeAllPriorityFeeLevels: true
          }
        }]
      })
    });
    
    const result = await response.json();
    
    if (result.error) {
      throw new Error(`Fee estimation failed: ${JSON.stringify(result.error)}`);
    }
    
    return result.result.priorityFeeLevels;
  }

  // Run the analysis
  analyzeAccountPriorityFees();
  ```
</Accordion>

## Kontentypen & Strategien

<Tabs>
  <Tab title="Programmkonten">
    Hochvolumige Programmkonten zeigen typischerweise höhere Prioritätsgebühren aufgrund von Wettbewerb.

    ```javascript theme={"system"}
    // Popular program accounts
    const programAccounts = [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // Token program
      "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL", // Associated token program
      "M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K"  // Metaplex program
    ];

    const programFees = await getPriorityFeeEstimate(connection, programAccounts, "Medium");
    console.log(`Program account fees: ${programFees} micro-lamports`);
    ```

    <Note>
      **Erwartetes Verhalten**: Höhere Gebühren aufgrund hoher Transaktionsvolumina und Wettbewerb.
    </Note>
  </Tab>

  <Tab title="Benutzer-Wallets">
    Aktive Benutzer-Wallets können je nach Aktivität unterschiedliche Gebührenmuster aufweisen.

    ```javascript theme={"system"}
    // Active user wallets
    const userWallets = [
      "USER_WALLET_1", // Active trader
      "USER_WALLET_2"  // Regular user
    ];

    const walletFees = await getPriorityFeeEstimate(connection, userWallets, "Medium");
    console.log(`User wallet fees: ${walletFees} micro-lamports`);
    ```

    <Tip>
      **Profi-Tipp**: Schließen Sie sowohl Absender- als auch Empfänger-Wallets ein, um genauere Schätzungen zu erhalten.
    </Tip>
  </Tab>

  <Tab title="Token-Konten">
    Spezifische Token-Konten können je nach Token-Beliebtheit unterschiedliche Muster zeigen.

    ```javascript theme={"system"}
    // Popular token accounts
    const tokenAccounts = [
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC mint
      "So11111111111111111111111111111111111111112",  // SOL mint
      "YOUR_TOKEN_ACCOUNT"                            // Your specific token account
    ];

    const tokenFees = await getPriorityFeeEstimate(connection, tokenAccounts, "Medium");
    ```
  </Tab>
</Tabs>

## Erweiterte Konfigurationsoptionen

<AccordionGroup>
  <Accordion title="Bewertung leerer Slots">
    Die `evaluateEmptySlotAsZero`-Option ist besonders nützlich für kontobasierte Schätzungen:

    ```javascript theme={"system"}
    async function compareEmptySlotHandling(accountKeys) {
      const withEmptyAsZero = await fetch(connection.rpcEndpoint, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate",
          params: [{
            accountKeys: accountKeys,
            options: { 
              priorityLevel: "Medium",
              evaluateEmptySlotAsZero: true // Default: true
            }
          }]
        })
      });

      const withoutEmptyAsZero = await fetch(connection.rpcEndpoint, {
        method: "POST", 
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate", 
          params: [{
            accountKeys: accountKeys,
            options: {
              priorityLevel: "Medium",
              evaluateEmptySlotAsZero: false
            }
          }]
        })
      });
      
      const result1 = await withEmptyAsZero.json();
      const result2 = await withoutEmptyAsZero.json();
      
      console.log(`With empty as zero: ${result1.result.priorityFeeEstimate}`);
      console.log(`Without empty as zero: ${result2.result.priorityFeeEstimate}`);
    }
    ```

    <Note>
      Wenn `true` (Standard), werden Slots ohne Transaktionen als Nullgebühren behandelt, anstatt ausgeschlossen zu werden. Dies bietet ausgewogenere Schätzungen für Konten mit sporadischer Aktivität.
    </Note>
  </Accordion>

  <Accordion title="Details einbeziehen">
    Fordern Sie detaillierte Informationen über die Gebührenmuster jedes Kontos an:

    ```javascript theme={"system"}
    async function getDetailedFeeEstimate(connection, accountKeys) {
      const response = await fetch(connection.rpcEndpoint, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate",
          params: [{
            accountKeys: accountKeys,
            options: { 
              includeDetails: true,
              priorityLevel: "Medium"
            }
          }]
        })
      });
      
      const result = await response.json();
      console.log("Detailed fee analysis:", result.result);
      return result.result;
    }
    ```

    Dies liefert zusätzliche Informationen darüber, wie die Gebühren für jedes Konto berechnet wurden.
  </Accordion>

  <Accordion title="Benutzerdefinierte Rückblicksperiode">
    Passen Sie die Anzahl der zur Gebührenschätzung analysierten Slots an:

    ```javascript theme={"system"}
    async function getCustomLookbackEstimate(accountKeys, lookbackSlots = 50) {
      const response = await fetch(connection.rpcEndpoint, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate",
          params: [{
            accountKeys: accountKeys,
            options: { 
              priorityLevel: "Medium",
              lookbackSlots: lookbackSlots  // 1-150, default is 150
            }
          }]
        })
      });
      
      const result = await response.json();
      return result.result.priorityFeeEstimate;
    }

    // Compare different lookback periods
    const shortTerm = await getCustomLookbackEstimate(accountKeys, 50);   // Recent trends
    const longTerm = await getCustomLookbackEstimate(accountKeys, 150);   // Historical average

    console.log(`Short-term estimate: ${shortTerm} micro-lamports`);
    console.log(`Long-term estimate: ${longTerm} micro-lamports`);
    ```

    <Tip>
      **Kleinerer Rückblick**: Kürzere, potenziell volatile Daten

      **Größerer Rückblick**: Stabilere, historische Kontexte
    </Tip>
  </Accordion>
</AccordionGroup>

## Best Practices für die Kontoauswahl

<CardGroup cols={1}>
  <Card title="Schreibbare Konten einbeziehen" icon="pen-to-square">
    **Priorität**: Konzentrieren Sie sich auf Konten, die geändert werden

    ```javascript theme={"system"}
    const writableAccounts = [
      "YOUR_WALLET",        // Paying fees
      "TOKEN_ACCOUNT",      // Being modified  
      "RECIPIENT_ACCOUNT"   // Receiving tokens
    ];
    ```
  </Card>

  <Card title="Wichtige Programme hinzufügen" icon="gear">
    **Kontext**: Relevante Programmkonten einbeziehen

    ```javascript theme={"system"}
    const programAccounts = [
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // Token program
      "CUSTOM_PROGRAM_ID"                           // Your program
    ];
    ```
  </Card>
</CardGroup>

## Fehlerbehandlung & Rückfallstrategien

<CodeGroup>
  ```javascript Robust Implementation theme={"system"}
  class AccountBasedFeeEstimator {
    constructor(connection) {
      this.connection = connection;
      this.fallbackFee = 10000; // 10k micro-lamports fallback
    }

    async getEstimate(accountKeys, priorityLevel = "Medium") {
      try {
        // Primary attempt
        const estimate = await this.getPrimaryEstimate(accountKeys, priorityLevel);
        return estimate;
      } catch (error) {
        console.warn("Primary estimate failed:", error.message);
        
        // Fallback to different configuration
        try {
          return await this.getFallbackEstimate(accountKeys, priorityLevel);
        } catch (fallbackError) {
          console.warn("Fallback estimate failed:", fallbackError.message);
          return this.fallbackFee;
        }
      }
    }

    async getPrimaryEstimate(accountKeys, priorityLevel) {
      const response = await fetch(this.connection.rpcEndpoint, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate",
          params: [{
            accountKeys: accountKeys,
            options: { 
              priorityLevel: priorityLevel,
              recommended: true 
            }
          }]
        })
      });

      const result = await response.json();
      if (result.error) {
        throw new Error(result.error.message);
      }
      
      return result.result.priorityFeeEstimate;
    }

    async getFallbackEstimate(accountKeys, priorityLevel) {
      // Try with fewer accounts or different settings
      const coreAccounts = accountKeys.slice(0, 3); // Take first 3 accounts
      
      const response = await fetch(this.connection.rpcEndpoint, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: "1",
          method: "getPriorityFeeEstimate",
          params: [{
            accountKeys: coreAccounts,
            options: { 
              priorityLevel: "Medium", // Use medium as fallback
              evaluateEmptySlotAsZero: true
            }
          }]
        })
      });

      const result = await response.json();
      if (result.error) {
        throw new Error(result.error.message);
      }
      
      return result.result.priorityFeeEstimate;
    }
  }

  // Usage
  const estimator = new AccountBasedFeeEstimator(connection);
  const fee = await estimator.getEstimate(accountKeys, "High");
  ```

  ```javascript Simple Error Handling theme={"system"}
  async function safeGetPriorityFee(accountKeys, priorityLevel = "Medium") {
    try {
      return await getPriorityFeeEstimate(connection, accountKeys, priorityLevel);
    } catch (error) {
      console.warn(`Priority fee estimation failed: ${error.message}`);
      
      // Return reasonable fallback based on priority level
      const fallbacks = {
        "Low": 1000,
        "Medium": 5000,
        "High": 15000,
        "VeryHigh": 50000
      };
      
      return fallbacks[priorityLevel] || 5000;
    }
  }
  ```
</CodeGroup>

## Einschränkungen & Überlegungen

<Warning>
  **Einschränkungen der kontobasierten Methode:**

  1. **Weniger genau für schreibgeschützte Konten** - Der Algorithmus fokussiert sich auf beschreibbare Konten
  2. **Keine anweisungsspezifische Analyse** - Kann spezifische Operationen nicht berücksichtigen
  3. **Abhängigkeit von Kontoaktivität** - Weniger genau für inaktive Konten
  4. **Keine Berücksichtigung der Transaktionsgröße** - Berücksichtigt nicht die Komplexität der Transaktion
</Warning>

<Note>
  **Wann zur serialisierten Transaktion aufsteigen:**

  * Anwendungen im Produktionsumfeld, die höchste Genauigkeit erfordern
  * Komplexe Transaktionen mit mehreren Anweisungen
  * Wenn anweisungsspezifische Gebührenmuster wichtig sind
  * Leistungsoptimierte Anwendungen
</Note>

## Verwandte Ressourcen

<CardGroup cols={2}>
  <Card title="Serialisierte Transaktionen" icon="file-code" href="/docs/de/priority-fee/estimating-fees-using-serialized-transaction">
    Genauerer Methode durch vollständige Transaktionsserialisierung
  </Card>

  <Card title="API-Referenz" icon="book" href="/docs/de/api-reference/priority-fee/getpriorityfeeestimate">
    Komplett API-Dokumentation und Parameter
  </Card>
</CardGroup>
