Skip to main content
Glama

hcs_verify_record

Verify compliance records on the Hedera blockchain to confirm their existence and ensure they remain untampered, using HBAR micropayments for each verification.

Instructions

Verify a compliance record exists on the Hedera blockchain and has not been tampered with. Costs 0.5 HBAR.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyYesYour HederaIntel API key
record_idYesRecord ID returned when the record was written
topic_idNoHCS topic ID where the record was written. Defaults to the HederaIntel platform topic.

Implementation Reference

  • The implementation of the 'hcs_verify_record' tool logic, which fetches messages from a Hedera HCS topic and verifies the record's integrity by comparing hashes.
    if (name === "hcs_verify_record") {
      const payment = chargeForTool("hcs_verify_record", args.api_key);
      const base = getMirrorNodeBase();
      const topicId = args.topic_id || PLATFORM_TOPIC;
    
      const response = await axios.get(
        `${base}/api/v1/topics/${topicId}/messages?limit=100&order=asc`
      );
    
      const messages = response.data.messages || [];
      let foundRecord = null;
    
      for (const msg of messages) {
        try {
          const content = Buffer.from(msg.message, "base64").toString("utf-8");
          const record = JSON.parse(content);
          if (record.record_id === args.record_id) {
            const { hash, ...recordWithoutHash } = record;
            const computedHash = crypto
              .createHash("sha256")
              .update(JSON.stringify(recordWithoutHash))
              .digest("hex");
    
            foundRecord = {
              record_id: record.record_id,
              record_type: record.record_type,
              entity_id: record.entity_id,
              written_at: record.written_at,
              consensus_timestamp: msg.consensus_timestamp,
              hash_valid: computedHash === hash,
              tampered: computedHash !== hash,
              sequence_number: msg.sequence_number,
            };
            break;
          }
        } catch (e) {
          continue;
        }
      }
    
      if (!foundRecord) {
        return {
          verified: false,
          record_id: args.record_id,
          topic_id: topicId,
          error: "Record not found on blockchain",
          payment,
        };
      }
    
      return {
        verified: true,
        tampered: foundRecord.tampered,
        hash_valid: foundRecord.hash_valid,
        topic_id: topicId,
        ...foundRecord,
        payment,
        timestamp: new Date().toISOString(),
      };
    }
  • Schema definition for the 'hcs_verify_record' tool.
    {
      name: "hcs_verify_record",
      description: "Verify a compliance record exists on the Hedera blockchain and has not been tampered with. Costs 1.0 HBAR.",
      inputSchema: {
        type: "object",
        properties: {
          topic_id: { type: "string", description: "HCS topic ID where the record was written. Defaults to the HederaIntel platform topic." },
          record_id: { type: "string", description: "Record ID returned when the record was written" },
          api_key: { type: "string", description: "Your HederaIntel API key" },
        },
        required: ["record_id", "api_key"],
      },
    },

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/mountainmystic/hederatoolbox'

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