> ## 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.

# programSubscribe

> Abonnieren Sie ein Programm, um Benachrichtigungen zu erhalten, wenn sich die Lamports oder Daten eines Kontos ändern, das dem angegebenen Programm gehört.

## Endpunkte

Websockets sind im Mainnet und Devnet mit den folgenden URLs verfügbar:

* **Mainnet** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **Devnet** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>Websockets haben einen 10-minütigen Inaktivitätstimer; es wird dringend empfohlen, Health-Checks zu implementieren und jede Minute Pings zu senden, um die Websocket-Verbindung aktiv zu halten.</Note>

## Berechtigungen

<ParamField query="api-key" type="string" required>
  Ihr Helius API-Schlüssel. Sie können einen kostenlos im [Dashboard](https://dashboard.helius.dev/api-keys) erhalten.
</ParamField>

## Körper

<ParamField body="params" type="array" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="programId" type="string" required>
      Pubkey des `program_id`, als Base-58 kodierter String.
    </ParamField>

    <ParamField body="config" type="object">
      Konfigurationsobjekt mit den folgenden Feldern:

      <ParamField body="commitment" type="string">
        Das Commitment-Level für das Abonnement. Kann sein `finalized`, `confirmed` oder `processed`.
      </ParamField>

      <ParamField body="filters" type="array">
        Array von anzuwendenden Filterobjekten.
      </ParamField>

      <ParamField body="encoding" type="string">
        Kodierungsformat für Kontodaten. Kann sein `base58`, `base64`, `base64+zstd` oder `jsonParsed`.

        * `base58` ist langsam
        * `jsonParsed` Kodierung versucht, programmspezifische Statusparser zu verwenden, um verständlichere und explizitere Kontostatusdaten zurückzugeben
        * Wenn `jsonParsed` angefordert wird, aber kein Parser gefunden werden kann, fällt das Feld auf binäre Kodierung zurück, erkennbar, wenn das Datenelement vom Typ String ist.
      </ParamField>

      <ParamField body="notifyOn" type="string" deprecated>
        **Veraltet — no-op ab Agave 4.2.** Die Einstellung `notifyOn` hat keine Wirkung. Das Feld wird zu einem späteren Zeitpunkt entfernt.
      </ParamField>
    </ParamField>
  </Expandable>
</ParamField>

## Antwort

<ResponseField name="result" type="integer">
  Abonnement-ID (erforderlich zum Abbestellen)
</ResponseField>

## Benachrichtigungsformat

Das Benachrichtigungsformat ist ein **einzelnes** Programmkonto-Objekt, wie es in der `getProgramAccounts` RPC HTTP-Methode zu sehen ist.

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "programSubscribe",
    "params": [
      "11111111111111111111111111111111",
      {
        "encoding": "base64",
        "filters": [{ "dataSize": 80 }]
      }
    ]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={"system"}
  {
    "jsonrpc": "2.0",
    "result": 24040,
    "id": 1
  }
  ```

  ```json Notification (base58) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "programNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5208469
        },
        "value": {
          "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
          "account": {
            "data": [
              "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
              "base58"
            ],
            "executable": false,
            "lamports": 33594,
            "owner": "11111111111111111111111111111111",
            "rentEpoch": 636,
            "space": 80
          }
        }
      },
      "subscription": 24040
    }
  }
  ```

  ```json Notification (jsonParsed) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "programNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5208469
        },
        "value": {
          "pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq",
          "account": {
            "data": {
              "program": "nonce",
              "parsed": {
                "type": "initialized",
                "info": {
                  "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX",
                  "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k",
                  "feeCalculator": {
                    "lamportsPerSignature": 5000
                  }
                }
              }
            },
            "executable": false,
            "lamports": 33594,
            "owner": "11111111111111111111111111111111",
            "rentEpoch": 636,
            "space": 80
          }
        }
      },
      "subscription": 24040
    }
  }
  ```
</ResponseExample>
