Skip to main content
Glama

hcs_write_record

Write tamper-evident compliance records to the Hedera blockchain for transactions, approvals, or audit events, providing record IDs and transaction proofs.

Instructions

Write a tamper-evident compliance record to the Hedera blockchain. Returns a record ID and transaction proof. If no topic_id is provided, writes to the shared HederaIntel platform topic. Costs 2 HBAR.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_keyYesYour HederaIntel API key
record_typeYesType of compliance record (e.g. transaction, approval, audit_event)
entity_idYesID of the entity this record relates to
dataYesThe compliance data to record (any JSON object)
topic_idNoHCS topic ID to write the record to. Defaults to the HederaIntel platform topic.

Implementation Reference

  • The handler for hcs_write_record which creates a record object, computes its SHA-256 hash, submits it to a Hedera HCS topic, and returns the result.
    if (name === "hcs_write_record") {
      const payment = chargeForTool("hcs_write_record", args.api_key);
      const client = getClient();
      const topicId = args.topic_id || PLATFORM_TOPIC;
    
      const record = {
        record_id: crypto.randomUUID(),
        record_type: args.record_type,
        entity_id: args.entity_id,
        data: args.data,
        written_at: new Date().toISOString(),
        written_by: process.env.HEDERA_ACCOUNT_ID,
      };
    
      const hash = crypto
        .createHash("sha256")
        .update(JSON.stringify(record))
        .digest("hex");
    
      record.hash = hash;
    
      const tx = await new TopicMessageSubmitTransaction()
        .setTopicId(topicId)
        .setMessage(JSON.stringify(record))
        .execute(client);
    
      const receipt = await tx.getReceipt(client);
    
      return {
        success: true,
        record_id: record.record_id,
        topic_id: topicId,
        entity_id: args.entity_id,
        record_type: args.record_type,
        hash,
        transaction_id: tx.transactionId.toString(),
        written_at: record.written_at,
        verification_note: "This record is permanently stored on the Hedera blockchain and cannot be altered.",
        payment,
        timestamp: new Date().toISOString(),
      };
    }
  • The schema definition for hcs_write_record.
    {
      name: "hcs_write_record",
      description: "Write a tamper-evident compliance record to the Hedera blockchain. Returns a record ID and transaction proof. If no topic_id is provided, writes to the shared HederaToolbox platform topic. Sends a webhook notification on every write. Costs 5 HBAR.",
      inputSchema: {
        type: "object",
        properties: {
          topic_id: { type: "string", description: "HCS topic ID to write the record to. Defaults to the HederaIntel platform topic." },
          record_type: { type: "string", description: "Type of compliance record (e.g. transaction, approval, audit_event)" },
          entity_id: { type: "string", description: "ID of the entity this record relates to" },
          data: { type: "object", description: "The compliance data to record (any JSON object)" },
          api_key: { type: "string", description: "Your HederaIntel API key" },
        },
        required: ["record_type", "entity_id", "data", "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