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

# getSignaturesForAddressの使用方法

> getSignaturesForAddressのユースケース、コード例、リクエストパラメータ、応答構造、ヒントを学びます。

この[`getSignaturesForAddress`](https://www.helius.dev/docs/api-reference/rpc/http/getsignaturesforaddress) RPCメソッドを使用すると、特定のアカウントアドレスが関与する確認済みトランザクション署名のリストを取得できます。これはアカウントのトランザクション履歴を取得するのに役立ちます。署名は新しいものから順に返されます。

<Tip>
  高度なフィルタリング、ソート、トークンアカウント履歴には、代わりに[`getTransactionsForAddress`](/ja/rpc/gettransactionsforaddress)を使用してください。`getSignaturesForAddress`には関連トークンアカウントが関与するトランザクションは含まれませんので注意してください。
</Tip>

## 一般的なユースケース

* **アカウントトランザクション履歴:** ユーザーウォレットの過去のトランザクションを表示します。トランザクション履歴のより高度な解析には、Helius の[Enhanced Transactions API](https://www.helius.dev/docs/enhanced-transactions)の使用を検討してください。
* **アクティビティ監査:** 特定のスマートコントラクトまたはアカウントに関連するすべてのトランザクションを確認します。
* **特定トランザクション検索:** 関与アドレスのみが知られている場合、アカウントの履歴を通じて特定のトランザクションを見つけます。
* **データインデクシング:** より迅速なクエリと分析のためにトランザクションのローカルインデックスを構築します。

## リクエストパラメータ

1. **`address`** (`string`): (必須) トランザクション署名を取得するアカウントのbase-58エンコードされた公開鍵。
2. **`options`** (`object`, 任意): 以下のフィールドを持つオプションの設定オブジェクト:
   * **`limit`** (`number`, 任意): 返される署名の最大数。デフォルトは1000で、最大許容数も1000。
   * **`before`** (`string`, 任意): base-58エンコードされたトランザクション署名。指定された場合、この署名の前からトランザクション検索を開始します。
   * **`until`** (`string`, 任意): base-58エンコードされたトランザクション署名。指定された場合、この署名まで（除外）トランザクションを検索します。
   * **`commitment`** (`string`, 任意): クエリに使用する[コミットメントレベル](https://www.helius.dev/blog/solana-commitment-levels)を指定します。サポートされている値は`finalized`または`confirmed`です。`processed`コミットメントはサポートされていません。省略された場合、RPCノードのデフォルトコミットメントが使用されます（通常は`finalized`）。
   * **`minContextSlot`** (`number`, 任意): リクエストを評価できる最小スロットを指定します。これは履歴トランザクションのフィルタではなく、ノードのコンテキストの最小スロットを設定します。

<Warning>
  **バッチ処理非対応**

  このアーカイブメソッドはバッチ処理をサポートしません。個別のリクエストのみを行ってください。
</Warning>

## 応答構造

JSON-RPC応答の`result`フィールドは、署名情報オブジェクトの配列です。各オブジェクトは以下の構造を持ちます:

* **`signature`** (`string`): base-58エンコードされたトランザクション署名。
* **`slot`** (`u64`): トランザクションが処理されたスロット。
* **`err`** (`object` | `null`): トランザクションが失敗した場合のエラーオブジェクト、成功した場合は`null`。
* **`memo`** (`string` | `null`): トランザクションに関連付けられたメモがある場合。
* **`blockTime`** (`i64` | `null`): トランザクションを含むブロックの推定生成時間（Unixタイムスタンプ）。利用不可の場合は`null`。
* **`confirmationStatus`** (`string` | `null`): トランザクションの確認ステータス（例: `processed`, `confirmed`, `finalized`）。利用不可（古いHelius応答など）の場合は`null`。

## 例

### 1. アドレスの最新署名を取得

この例では、指定されたアドレスに対する最大1000件の最新トランザクション署名を取得します。

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

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

  async function getLatestSignatures() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    // Replace with the public key you want to query
    const address = new PublicKey('11111111111111111111111111111111'); 

    try {
      const signatures = await connection.getSignaturesForAddress(address);
      if (signatures && signatures.length > 0) {
        console.log(`Found ${signatures.length} signatures:`);
        signatures.forEach((sigInfo, index) => {
          console.log(`--- Signature ${index + 1} ---`);
          console.log(`  Signature: ${sigInfo.signature}`);
          console.log(`  Slot: ${sigInfo.slot}`);
          console.log(`  Block Time: ${sigInfo.blockTime ? new Date(sigInfo.blockTime * 1000).toLocaleString() : 'N/A'}`);
          console.log(`  Error: ${JSON.stringify(sigInfo.err)}`);
          console.log(`  Memo: ${sigInfo.memo || 'N/A'}`);
          console.log(`  Confirmation Status: ${sigInfo.confirmationStatus || 'N/A'}`);
        });
      } else {
        console.log('No signatures found for this address.');
      }
    } catch (error) {
      console.error('Error fetching signatures:', error);
    }
  }

  getLatestSignatures();
  ```
</CodeGroup>

### 2. 制限付きで署名を取得

この例では、アドレスに対する指定された数の最近のトランザクション署名を取得します。

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  # Replace TARGET_ACCOUNT_ADDRESS with the address you want to query
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSignaturesForAddress",
      "params": [
        "TARGET_ACCOUNT_ADDRESS",
        {
          "limit": 5 
        }
      ]
    }'
  ```

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

  async function getLimitedSignatures() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    // Replace with the public key you want to query
    const address = new PublicKey('Vote111111111111111111111111111111111111111'); 
    const limit = 5;

    try {
      const signatures = await connection.getSignaturesForAddress(address, { limit });
      console.log(`Fetched up to ${limit} signatures:`);
      signatures.forEach((sigInfo, index) => {
        console.log(`${index + 1}. Signature: ${sigInfo.signature}, Slot: ${sigInfo.slot}`);
      });
    } catch (error) {
      console.error(`Error fetching limited signatures for ${address.toBase58()}:`, error);
    }
  }

  getLimitedSignatures();
  ```
</CodeGroup>

### 3. トランザクション履歴のページング

この例では、パラメータ`before`を使用してトランザクション履歴をバッチ処理で取得する方法を示します。

<CodeGroup>
  ```bash cURL theme={"system"}
  # Initial request (get the latest 2)
  # Replace <api-key> with your Helius API key
  # Replace TARGET_ACCOUNT_ADDRESS with the address you want to query
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSignaturesForAddress",
      "params": [
        "TARGET_ACCOUNT_ADDRESS",
        { "limit": 2 }
      ]
    }'

  # Suppose the last signature from the above response was LAST_SIGNATURE_FROM_PREVIOUS_BATCH
  # Fetch the next 2 transactions before that one
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getSignaturesForAddress",
      "params": [
        "TARGET_ACCOUNT_ADDRESS",
        { 
          "limit": 2,
          "before": "LAST_SIGNATURE_FROM_PREVIOUS_BATCH" 
        }
      ]
    }'
  ```

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

  async function paginateSignatures() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    // Replace with the public key you want to query - e.g. a known active address
    const address = new PublicKey('Vote111111111111111111111111111111111111111'); 
    const batchSize = 2;
    let lastSignature = null;
    let allSignatures = [];
    const maxPages = 3; // Limit how many pages we fetch for this example

    try {
      for (let i = 0; i < maxPages; i++) {
        console.log(`Fetching page ${i + 1}...`);
        const options = { limit: batchSize };
        if (lastSignature) {
          options.before = lastSignature;
        }

        const signatures = await connection.getSignaturesForAddress(address, options);
        
        if (signatures.length === 0) {
          console.log('No more signatures found.');
          break;
        }

        signatures.forEach(sigInfo => {
          allSignatures.push(sigInfo.signature);
          console.log(`  Found: ${sigInfo.signature} in slot ${sigInfo.slot}`);
        });
        
        lastSignature = signatures[signatures.length - 1]?.signature;

        if (signatures.length < batchSize || !lastSignature) {
           console.log('Fetched all available signatures or reached end of page.');
           break;
        }
        // Optional: Add a small delay if making many sequential requests
        // await new Promise(resolve => setTimeout(resolve, 200)); 
      }
      console.log(`
  Total signatures fetched (${allSignatures.length}):`);
      allSignatures.forEach((sig, idx) => console.log(`${idx + 1}. ${sig}`));

    } catch (error) {
      console.error('Error paginating signatures:', error);
    }
  }

  paginateSignatures();
  ```
</CodeGroup>

## 開発者向けヒント

* **ページネーション:** 活動中のアカウントの完全なトランザクション履歴を取得するには、複数のリクエストを行い、前回のバッチで受け取った最後の署名と`limit`パラメータを使用します。
* **レートリミット:** 大量のトランザクション履歴を取得する際には、RPCノードのレートリミットに注意してください。
* **順序:** 署名は常に新しいものから古いものへの順序で返されます。
* **`limit` パラメータ:** `limit`パラメータは1から1000の範囲で指定可能です。指定されない場合、デフォルトは1000です。
* **`until` パラメータ:** このパラメータを使用すると、既知の古い署名に達した場合に署名の取得を停止できます。特定のポイントまでのトランザクションのみを必要とする場合に有用です。
* **`minContextSlot`:** このパラメータは履歴トランザクションをフィルタしません。これは、ノードがリクエストの評価に使用するコンテキストの最小スロットを指定します。ノードの状態がこのスロットよりも古い場合、エラーを返すことがあります。
* **トランザクション詳細:** このメソッドは署名と基本情報のみを返します。完全なトランザクション詳細を取得するには、各署名で`getTransaction`メソッドを使用します。
* **トークンアカウントの制限:** このメソッドは提供されたアドレスを直接参照するトランザクションのみを返します。アドレスが所有するトークンアカウントに関与するトランザクションは含まれません。関連トークンアカウントを含む完全なトークン履歴には[`getTransactionsForAddress`](/ja/rpc/gettransactionsforaddress)を`tokenAccounts`フィルタと共に使用してください。

`getSignaturesForAddress`のページネーションオプションを使用すると、任意のSolanaアドレスのトランザクション履歴を効果的に取得および管理できます。

## 関連メソッド

<CardGroup cols={2}>
  <Card title="getTransactionsForAddress" href="/ja/rpc/gettransactionsforaddress">
    高度なフィルタリング、ソート、トークンアカウント履歴
  </Card>

  <Card title="getTransaction" href="/ja/api-reference/rpc/http/gettransaction">
    署名から完全なトランザクション詳細を取得
  </Card>
</CardGroup>
