Skip to main content
Glama

pot_query

Query Proof of Time history from local logs and on-chain subgraph to verify transaction timing and resolve payment disputes.

Instructions

Query Proof of Time history from local log and on-chain subgraph.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startTimeNoStart time (unix ms). Default: 24h ago
endTimeNoEnd time (unix ms). Default: now
limitNoMax entries to return. Default: 100, max: 1000

Implementation Reference

  • The 'potQuery' function implements the 'pot_query' tool, which retrieves proof-of-time anchor logs filtered by time and limit, combining in-memory logs with data from a subgraph.
    export async function potQuery(args: {
      startTime?: number;
      endTime?: number;
      limit?: number;
    }): Promise<unknown> {
      telemetryIncrement("pot_query");
    
      const limit = Math.min(args.limit ?? 100, 1000);
      const now = Date.now();
      const startTime = args.startTime ?? now - 86400_000;
      const endTime = args.endTime ?? now;
    
      // Filter from in-memory log
      const filtered = potLog
        .filter((e) => e.createdAt >= startTime && e.createdAt <= endTime)
        .slice(-limit);
    
      // Best-effort subgraph query
      let subgraphEntries: unknown[] = [];
      try {
        const query = `{
          potAnchors(
            first: ${limit},
            orderBy: blockTimestamp,
            orderDirection: desc,
            where: { blockTimestamp_gte: "${Math.floor(startTime / 1000)}", blockTimestamp_lte: "${Math.floor(endTime / 1000)}" }
          ) {
            id
            potHash
            blockTimestamp
            txHash
          }
        }`;
    
        const controller = new AbortController();
        const timeout = setTimeout(() => controller.abort(), 5000);
        const resp = await fetch(SUBGRAPH_URL, {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ query }),
          signal: controller.signal,
        });
        clearTimeout(timeout);
    
        if (resp.ok) {
          const json = (await resp.json()) as { data?: { potAnchors?: unknown[] } };
          subgraphEntries = json.data?.potAnchors ?? [];
        }
      } catch {
        // Subgraph unavailable — local log still returned
      }
    
      return serialize({
        local: filtered,
        subgraph: subgraphEntries,
        totalLocal: potLog.length,
        query: { startTime, endTime, limit },
      });
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Helm-Protocol/openttt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server