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

# getSlotLeader 사용 방법

> getSlotLeader 사용 사례, 코드 예제, 요청 매개 변수, 응답 구조 및 팁을 알아보세요.

[`getSlotLeader`](https://www.helius.dev/docs/api-reference/rpc/http/getslotleader) RPC 메서드는 지정된 커밋 수준에서 노드의 보기에 따라 현재 블록 생성을 위한 리더인 검증자의 공개 키를 반환합니다. 리더는 현재 슬롯에 대한 블록을 생성할 책임이 있습니다.

## 일반적인 사용 사례

* **현재 블록 생성자 식별:** 현재 블록을 생성하도록 예정된 검증자를 알아냅니다.
* **네트워크 모니터링:** 슬롯 리더의 회전을 관찰합니다.
* **트랜잭션 문제 디버깅:** 일부 고급 시나리오에서는 트랜잭션이 리더에게 직접 제출되는 경우 현재 슬롯 리더를 아는 것이 중요할 수 있습니다 (일반적인 클라이언트 측 실무는 아님).

## 요청 매개 변수

이 메서드는 첫 번째 매개 변수로 선택적 구성 객체를 받습니다:

1. **`options`** (`object`, 선택 사항): 다음 필드를 포함하는 선택적 구성 객체입니다:
   * **`commitment`** (`string`, 선택 사항): 쿼리에 대한 [커밋 수준](https://www.helius.dev/blog/solana-commitment-levels)을 지정합니다. 지원되는 값은 `finalized`, `confirmed`, 혹은 `processed`입니다. 생략 시 RPC 노드의 기본 커밋이 사용됩니다 (보통 `finalized`). 슬롯 리더는 이 커밋 수준에 맞는 슬롯을 기반으로 결정됩니다.
   * **`minContextSlot`** (`number`, 선택 사항): 요청을 평가할 수 있는 최소 슬롯입니다. 이를 통해 노드의 컨텍스트에 대한 최소 슬롯을 설정합니다.

## 응답 구조

JSON-RPC 응답의 `result` 필드는 현재 슬롯 리더의 공개 키(정체성)를 나타내는 단일 base-58 인코딩 문자열입니다.

**예시 응답:**

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "result": "ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS",
  "id": 1
}
```

## 예시

### 1. 현재 슬롯 리더 가져오기 (기본 커밋)

이 예시는 노드의 기본 커밋 수준(보통 `finalized`)을 사용하여 현재 슬롯 리더를 가져옵니다.

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSlotLeader"
    }'
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  // Replace <api-key> with your Helius API key
  const { Connection } = require('@solana/web3.js');

  async function getCurrentSlotLeader() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const slotLeader = await connection.getSlotLeader();
      console.log('Current slot leader (default commitment):', slotLeader);
    } catch (error) {
      console.error('Error fetching current slot leader:', error);
    }
  }

  getCurrentSlotLeader();
  ```
</CodeGroup>

### 2. `confirmed` 커밋으로 현재 슬롯 리더 가져오기

이 예시는 `confirmed` 커밋에 도달한 최신 슬롯에 대한 슬롯 리더를 가져옵니다.

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSlotLeader",
      "params": [
        {
          "commitment": "confirmed"
        }
      ]
    }'
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  // Replace <api-key> with your Helius API key
  const { Connection } = require('@solana/web3.js');

  async function getConfirmedSlotLeader() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const slotLeader = await connection.getSlotLeader('confirmed');
      console.log('Current slot leader (confirmed commitment):', slotLeader);
      // Note: For @solana/web3.js v1.30.0 and later, you can pass commitment directly.
      // For older versions or more complex options, use an object:
      // const slotLeader = await connection.getSlotLeader({ commitment: 'confirmed' });
    } catch (error) {
      console.error('Error fetching confirmed slot leader:', error);
    }
  }

  getConfirmedSlotLeader();
  ```
</CodeGroup>

## 개발자 팁

* **동적 특성:** 슬롯 리더는 자주 변경됩니다 (보통 4슬롯마다). 이 호출의 결과는 노드의 현재 보기와 선택한 커밋에 따라 시점의 스냅샷입니다.
* **커밋 수준:** 커밋 수준은 리더를 결정하기 위해 "현재"로 간주되는 슬롯에 영향을 줍니다. `processed`를 사용하면 노드가 인식하는 가장 최신 슬롯의 리더를 얻을 수 있으며, 이는 빠르게 변경될 수 있으며 더 넓은 네트워크에 의해 아직 확인되지 않을 수 있습니다.
* **리더 일정:** 슬롯 리더의 순서는 각 에포크 시작 시 계산되는 리더 일정에 의해 결정됩니다. [슬롯, 블록, 에포크](https://www.helius.dev/blog/solana-slots-blocks-and-epochs)에 대한 가이드는 이 과정에 대한 자세한 정보를 제공합니다. 다가오는 리더에 대한 포괄적인 보기를 얻으려면 `getLeaderSchedule`를 사용하세요.
* **노드의 관점:** 반환된 슬롯 리더는 쿼리하는 특정 RPC 노드에 사용 가능한 정보에 기반합니다. 네트워크 지연으로 인해 다른 노드에서는 약간의 차이가 있을 수 있습니다.

`getSlotLeader`는 현재 블록 생성에 책임이 있는 검증자를 빠르게 식별하기 위한 방법을 제공합니다. 리더 회전에 대한 더 넓은 보기를 원한다면 `getLeaderSchedule`를 고려하세요.

## 관련 메서드

<CardGroup cols={2}>
  <Card title="getLeaderSchedule" href="/docs/ko/api-reference/rpc/http/getleaderschedule">
    에포크에 대한 전체 리더 일정 가져오기
  </Card>

  <Card title="getSlotLeaders" href="/docs/ko/api-reference/rpc/http/getslotleaders">
    다가오는 슬롯의 리더 가져오기
  </Card>
</CardGroup>
