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

> 지정된 프로그램이 소유한 계정의 lamports 또는 데이터가 변경될 때 알림을 받기 위해 프로그램을 구독하세요.

## 엔드포인트

메인넷 및 데브넷에서 다음 URL을 통해 웹소켓을 사용할 수 있습니다:

* **메인넷** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **데브넷** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>웹소켓은 10분의 비활성 타이머가 있습니다; 건강 검진을 구현하고 매 분 핑을 보내 웹소켓 연결을 유지하는 것이 강력히 권장됩니다.</Note>

## 권한

<ParamField query="api-key" type="string" required>
  귀하의 Helius API 키입니다. [대시보드](https://dashboard.helius.dev/api-keys)에서 무료로 얻을 수 있습니다.
</ParamField>

## 본문

<ParamField body="params" type="array" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="programId" type="string" required>
      base-58로 인코딩된 문자열로 제공되는 `program_id`의 퍼브키.
    </ParamField>

    <ParamField body="config" type="object">
      다음 필드를 포함하는 구성 객체:

      <ParamField body="commitment" type="string">
        구독에 대한 커밋 수준입니다. `finalized`, `confirmed`, 또는 `processed`가 될 수 있습니다.
      </ParamField>

      <ParamField body="filters" type="array">
        적용할 필터 객체의 배열입니다.
      </ParamField>

      <ParamField body="encoding" type="string">
        계정 데이터의 인코딩 형식입니다. `base58`, `base64`, `base64+zstd`, 또는 `jsonParsed`가 될 수 있습니다.

        * `base58`는 느립니다
        * `jsonParsed` 인코딩은 더 인간 친화적이고 명확한 계정 상태 데이터를 반환하기 위해 프로그램 전용 상태 파서를 사용하려고 시도합니다
        * `jsonParsed`가 요청되었지만 파서를 찾을 수 없는 경우, 필드는 문자열 유형 데이터 필드에서 감지할 수 있는 이진 인코딩으로 돌아갑니다.
      </ParamField>

      <ParamField body="notifyOn" type="string">
        Helius 고유의 확장 기능입니다. 기본값은 `lock`이며, `write`이 될 수 있습니다.

        * `lock`는 트랜잭션이 계정에 쓰여지지 않더라도 트랜잭션이 쓰기 잠금을 걸 경우 모든 일치하는 계정에 대한 알림을 보냅니다.
        * `write`는 트랜잭션이 실제로 계정에 쓸 경우에만 알림을 보내 바쁜 계정에 대한 중복 무활동 업데이트를 줄입니다. 동일한 데이터가 쓰여지는 경우에도 쓰기로 간주되어 전달됩니다
        * 인식되지 않은 값은 `lock`로 돌아갑니다

        [notifyOn 필터링](/docs/ko/rpc/websocket/notify-on-filtering)을 참조하세요.
      </ParamField>
    </ParamField>
  </Expandable>
</ParamField>

## 응답

<ResponseField name="result" type="integer">
  구독 ID (구독 취소에 필요)
</ResponseField>

## 알림 형식

알림 형식은 `getProgramAccounts` RPC HTTP 메서드에서 볼 수 있는 **단일** 프로그램 계정 객체입니다.

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