> For the complete documentation index, see [llms.txt](https://docs.coinvera.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coinvera.io/integration/solana/rpc/getslotleader.md).

# getSlotLeader

The `getSlotLeader` RPC method in **CoinVera** returns the **public key** of the validator currently designated as the **block producer** for the current slot. This determination is made according to the node’s view at a specified **commitment level**.

***

#### ✅ Common Use Cases

* **Identifying the Current Block Producer**\
  Determine which validator is currently responsible for producing blocks.
* **Network Monitoring**\
  Track how slot leadership rotates among validators.
* **Debugging Transaction Issues**\
  In advanced setups, it may be useful to identify the leader—especially when submitting transactions directly to leader nodes.

***

#### 🧾 Request Parameters

`getSlotLeader` accepts an **optional configuration object**:

* `options` (object, optional):
  * `commitment` (string):\
    One of `finalized`, `confirmed`, or `processed`.\
    Defaults to the node’s standard (usually `finalized`).
  * `minContextSlot` (number):\
    Minimum slot the request must be evaluated at. Ensures the node is sufficiently up to date before responding.

***

#### 📦 Response Structure

Returns a single **base-58 encoded public key** string representing the current slot leader.

```json
{
  "result": "5Y6g8zWcR9GVoHqGnBbPmgzUdu1tHuCVDRKLv7fP5Xed"
}
```

***

#### 🧪 Examples

**1. Get Current Slot Leader (Default Commitment)**

Fetches the current leader using the node's default commitment (usually `finalized`).

```json
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getSlotLeader"
}
```

**2. Get Slot Leader with `confirmed` Commitment**

Fetches the leader for the most recently confirmed slot.

```json
{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getSlotLeader",
    "params": [
      {
        "commitment": "confirmed"
      }
    ]
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getSlotLeader(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getSlotLeader',
        "params": [
            {
              "commitment": "confirmed"
            }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getSlotLeader(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_slot_leader(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getSlotLeader',
                'params': [
                    {
                        'commitment': 'confirmed'
                    }
                ]
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_slot_leader(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": "bkpk9KVsDRfrArzzmkJ9mPEvbXfQxczzQYR3QMGiR8Z",
  "id": 1
}
```

***

#### 💡 Developer Tips

* **Leaders Rotate Rapidly**\
  Slot leaders change roughly every **4 slots**, making the returned value a momentary snapshot.
* **Commitment Level Impacts Accuracy**
  * `processed`: Most recent view, may be unstable.
  * `confirmed` or `finalized`: Safer, more consistent results.
* **Understand Leader Scheduling**\
  The rotation is based on a **leader schedule**, calculated at the start of each **epoch**. For future or historical slots, use `getLeaderSchedule`.
* **Node Perspective Matters**\
  Each RPC node operates based on its own network view. Results may vary slightly across nodes due to latency or forks.

***

The `getSlotLeader` method provides a fast and simple way to identify the current validator responsible for producing blocks. For a broader perspective of validator rotation, use the more detailed `getLeaderSchedule` RPC method.
