mcpField
Q
query

query

github.com/aibtcdevデータ・データベース11182 回インストール2 日前に更新
リポジトリ

query について

Query SkillはHiro APIを通じてStacksネットワークとブロックチェーンを照会するスキルです。アカウント、ブロック、コントラクト、ネットワークの確認に加え、メンプールやイベント、読み取り専用関数にも対応します。

主な機能

  1. 01STX手数料の見積もり取得
  2. 02アカウント残高と取引履歴の確認
  3. 03ブロックとネットワーク状態の照会
  4. 04コントラクト情報とイベントの取得
  5. 05読み取り専用関数の呼び出し

活用シーン

  1. 01アカウント残高とnonceの確認
  2. 02保留中の取引とネットワーク状態の確認
  3. 03コントラクトABIやイベントの取得
  4. 04読み取り専用コントラクト関数の結果取得

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/aibtcdev/skills --skill query

インストール後、Claude Code で/queryを入力して読み込まれたか確認します。

同梱ファイルAGENT.mdquery.ts

詳細

クエリスキル

Hiro API を使用して、Stacks ネットワークとブロックチェーンのクエリ操作を提供します。ほとんどのクエリではウォレットは不要です。get-account-info と get-account-transactions は、アドレスが指定されていない場合、アクティブなウォレットアドレスにフォールバックします。

使用方法

bun run query/query.ts <subcommand> [options]

サブコマンド

get-stx-fees

優先度ごとの現在の STX 手数料の見積もりを取得します。

bun run query/query.ts get-stx-fees

出力:

{
  "network": "mainnet",
  "fees": {
    "low": { "microStx": 1000, "stx": "0.001 STX", "description": "Lower fee, may take longer to confirm" },
    "medium": { "microStx": 2500, "stx": "0.0025 STX", "description": "Standard fee, typical confirmation time" },
    "high": { "microStx": 5000, "stx": "0.005 STX", "description": "Higher fee, faster confirmation" }
  },
  "byTransactionType": {
    "tokenTransfer": { "low": 1000, "medium": 2500, "high": 5000 },
    "contractCall": { "low": 1500, "medium": 3000, "high": 6000 },
    "smartContract": { "low": 2000, "medium": 4000, "high": 8000 }
  },
  "unit": "micro-STX",
  "note": "1 STX = 1,000,000 micro-STX. Fees are estimates based on current mempool conditions."
}
get-account-info

nonce と STX 残高を含むアカウント情報を取得します。

bun run query/query.ts get-account-info [--address <stxAddress>]

オプション:

  • --address(任意)— 確認する Stacks アドレス(省略した場合はアクティブなウォレットを使用します)

出力:

{
  "address": "SP...",
  "network": "mainnet",
  "nonce": 42,
  "balance": { "microStx": "1000000000", "stx": "1000 STX" },
  "explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}
get-account-transactions

Stacks アカウントのトランザクション履歴を取得します。

bun run query/query.ts get-account-transactions [--address <stxAddress>] [--limit 20] [--offset 0]

オプション:

  • --address(任意)— Stacks アドレス(省略した場合はアクティブなウォレットを使用します)
  • --limit(任意)— 結果の最大数(デフォルト:20)
  • --offset(任意)— ページネーションのオフセット(デフォルト:0)

出力:

{
  "address": "SP...",
  "network": "mainnet",
  "total": 150,
  "limit": 20,
  "offset": 0,
  "transactions": [
    {
      "txId": "0x...",
      "type": "token_transfer",
      "status": "success",
      "sender": "SP...",
      "blockHeight": 145000,
      "fee": "1000",
      "explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
    }
  ],
  "explorerUrl": "https://explorer.hiro.so/address/SP...?chain=mainnet"
}
get-block-info

特定の Stacks ブロックに関する情報を取得します。

bun run query/query.ts get-block-info --height-or-hash <value>

オプション:

  • --height-or-hash(必須)— ブロックの高さ(整数)またはブロックハッシュ(0x で始まる値)

出力:

{
  "network": "mainnet",
  "hash": "0x...",
  "height": 145000,
  "canonical": true,
  "burnBlockHeight": 840000,
  "burnBlockTime": 1700000000,
  "burnBlockTimeIso": "2024-01-01T00:00:00.000Z",
  "txCount": 12,
  "txIds": ["0x..."]
}
get-mempool-info

Stacks のメモリプールにある保留中のトランザクションを取得します。

bun run query/query.ts get-mempool-info [--sender-address <addr>] [--limit 20] [--offset 0]

オプション:

  • --sender-address(任意)— 送信者アドレスで絞り込みます
  • --limit(任意)— 結果の最大数(デフォルト:20)
  • --offset(任意)— ページネーションのオフセット(デフォルト:0)

出力:

{
  "network": "mainnet",
  "total": 5,
  "limit": 20,
  "offset": 0,
  "transactions": [
    {
      "txId": "0x...",
      "type": "contract_call",
      "sender": "SP...",
      "fee": "2500",
      "nonce": 43,
      "receiptTime": "2024-01-01T00:00:00.000Z",
      "explorerUrl": "https://explorer.hiro.so/txid/0x...?chain=mainnet"
    }
  ]
}
get-contract-info

ABI を含む、スマートコントラクトに関する情報を取得します。

bun run query/query.ts get-contract-info --contract-id <address.contract-name>

オプション:

  • --contract-id(必須)— address.contract-name 形式のコントラクト ID

出力:

{
  "contractId": "SP...contract-name",
  "network": "mainnet",
  "txId": "0x...",
  "blockHeight": 140000,
  "functions": [
    { "name": "transfer", "access": "public", "args": [...], "outputs": {...} }
  ],
  "variables": [...],
  "maps": [...],
  "fungibleTokens": [...],
  "nonFungibleTokens": [...],
  "explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}
get-contract-events

スマートコントラクトが発行したイベントを取得します。

bun run query/query.ts get-contract-events --contract-id <address.contract-name> [--limit 20] [--offset 0]

オプション:

  • --contract-id(必須)— address.contract-name 形式のコントラクト ID
  • --limit(任意)— 結果の最大数(デフォルト:20)
  • --offset(任意)— ページネーションのオフセット(デフォルト:0)

出力:

{
  "contractId": "SP...contract-name",
  "network": "mainnet",
  "limit": 20,
  "offset": 0,
  "events": [...],
  "explorerUrl": "https://explorer.hiro.so/txid/SP...contract-name?chain=mainnet"
}
get-network-status

Stacks ネットワークの現在のステータスを取得します。

bun run query/query.ts get-network-status

出力:

{
  "network": "mainnet",
  "serverVersion": "stacks-node 2.4.0.0.0",
  "status": "ready",
  "chainTip": { "block_height": 145000, "block_hash": "0x..." },
  "coreInfo": {
    "peerVersion": 4026533888,
    "stacksTipHeight": 145000,
    "burnBlockHeight": 840000,
    "networkId": 1
  }
}
call-read-only

スマートコントラクトの読み取り専用関数を呼び出します。

bun run query/query.ts call-read-only --contract-id <id> --function-name <name> [--args <json>] [--sender <address>]

オプション:

  • --contract-id(必須)— address.contract-name 形式のコントラクト ID
  • --function-name(必須)— 読み取り専用関数の名前
  • --args(任意)— 16 進数エンコードされた Clarity 値の JSON 配列(デフォルト:[])
  • --sender(任意)— 送信者アドレス(省略した場合はアクティブなウォレット、またはコントラクトアドレスを使用します)

--args オプションには、16 進数エンコードされた Clarity 値の JSON 配列を指定します。値のエンコードには @stacks/transactions を使用します。たとえば、uintCV(1) をシリアライズして 16 進数にすると、"0100000000000000000000000000000001" になります。

出力:

{
  "contractId": "SP...contract-name",
  "functionName": "get-balance",
  "network": "mainnet",
  "okay": true,
  "result": "0x0100000000000000000000000000000064",
  "cause": null
}

注意事項

  • すべてのクエリは Hiro API(api.mainnet.hiro.so または api.testnet.hiro.so)を使用します
  • ネットワークは NETWORK 環境変数によって制御されます(デフォルト:testnet)
  • get-account-info と get-account-transactions は、アクティブなウォレットアドレスにフォールバックします
  • call-read-only は、アクティブなウォレットがない場合、送信者としてコントラクト自身のアドレスにフォールバックします

コメント