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

# getBlockTime 사용법

> getBlockTime 사용 사례, 코드 예제, 요청 매개변수, 응답 구조 및 팁을 학습합니다.

[`getBlockTime`](https://www.helius.dev/docs/api-reference/rpc/http/getblocktime) RPC 메서드는 슬롯 번호로 식별된 특정 블록의 추정 생성 시간을 제공합니다. 시간은 Unix 타임스탬프(Unix epoch 이후 초)로 반환됩니다.

이 메서드는 블록 생성과 실제 시간 사이를 연관 지어야 할 때 유용합니다.

<Warning>
  **더 나은 성능을 위한 배치 사용 금지**

  보관 메서드를 배치하면 대기 시간이 크게 증가합니다. 10개 이상의 요청 배치는 허용되지 않습니다.
</Warning>

## 일반적인 사용 사례

* **이벤트 타임스탬핑:** 특정 블록이 생성된 시점을 파악하여 온체인 이벤트에 타임스탬프를 지정합니다.
* **블록 생성 간격 분석:** 블록 간 시간 차이를 계산합니다 (더 자세한 분석을 위해서는 다른 메서드를 결합할 수 있습니다).
* **오프체인 데이터 연관:** 블록 생성 시간을 맞추어 오프체인 이벤트나 데이터를 온체인 활동과 연관시킵니다.

## 요청 매개변수

`getBlockTime` 메서드는 한 가지 매개변수를 받습니다:

1. **`slot`** (u64, 필수): 예상 생성 시간을 검색할 블록의 슬롯 번호입니다.

## 응답 구조

JSON-RPC 응답의 `result` 필드는 다음 중 하나입니다:

* **`timestamp`** (i64): Unix 타임스탬프(Unix epoch 이후 초)로서의 예상 생성 시간입니다.
* **`null`**: 지정된 블록에 대한 타임스탬프가 없는 경우(예: 데이터가 잘려서 블록이 매우 오래되었거나 블록이 건너뛰어지고 관련 타임스탬프가 없는 경우).

## 예제

### 1. 특정 블록의 예상 시간 가져오기

이 예제는 특정 슬롯에 대한 예상 생성 시간을 가져옵니다. `SLOT_NUMBER_TO_QUERY`를 대상 네트워크(Mainnet Beta 또는 Devnet 등)의 실제, 최근, 확인된 슬롯으로 교체해야 합니다.

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace SLOT_NUMBER_TO_QUERY with a valid slot, e.g., a recent one from an explorer
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getBlockTime",
      "params": [
        SLOT_NUMBER_TO_QUERY 
      ]
    }'
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  const { Connection } = require('@solana/web3.js');

  async function getSpecificBlockTime(slotToQuery) {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const blockTime = await connection.getBlockTime(slotToQuery);
      if (blockTime !== null) {
        console.log(`Estimated time for slot ${slotToQuery}: ${new Date(blockTime * 1000).toISOString()} (Unix: ${blockTime})`);
      } else {
        console.log(`Timestamp not available for slot ${slotToQuery}.`);
      }
    } catch (error) {
      console.error('Error fetching block time:', error);
    }
  }

  // Example usage: Replace with a recent, valid slot number from Mainnet Beta
  // You can find recent slots on Solana explorers like Solscan or SolanaFM
  const slotToQuery = 300000000; // Replace with an actual slot number
  getSpecificBlockTime(slotToQuery);
  ```
</CodeGroup>

## 개발자 팁

* **타임스탬프 가용성:** 타임스탬프는 특히 매우 오래된 블록이나 건너뛴 슬롯에서는 모든 블록에 대해 사용 가능하지 않을 수 있습니다. 이 경우 메서드는 `null`를 반환합니다.
* **추정치:** 시간은 *예상치*입니다. 이는 검증자의 투표 타임스탬프의 스테이크 가중 평균에서 파생됩니다. 일반적으로 정확하지만 블록 해시와 같은 절대적으로 안전한 타임스탬프는 아닙니다.
* **노드 의존성:** 사용성과 정밀도는 쿼리한 RPC 노드에 따라 약간 달라질 수 있으며, 특히 매우 최근(아직 확정되지 않은) 블록의 경우가 그렇습니다.

이 가이드는 Solana 네트워크의 주어진 블록에 대한 예상 생성 타임스탬프를 검색하는 방법을 설명합니다.
