Documentation
HashGraph is the semantic infrastructure layer for HashKey Chain. It transforms raw, unreadable blockchain bytecode into highly structured, AI-readable Protocol Graphs.
Most blockchain tools stop at the ABI. They tell computers how to call a contract, but not what the contract actually does. HashGraph bridges this gap by deterministically compiling a contract's relationships, roles, dependencies, and metadata into a singular Protocol Graph, and then mapping a semantic intent layer on top of it.
Quick Start
HashGraph is designed to be consumed directly by AI agents. You can run the MCP Server with zero configuration.
1. Global Installation
Install the HashGraph MCP server globally on your machine:
2. Run via NPX (Direct execution)
Alternatively, run the server instantly without local installation:
Compiler Pipeline
HashGraph is built on a strict deterministic pipeline. The pipeline operates as a series of pure functions. Data flows strictly downwards.
The Deterministic Compiler
The core innovation of HashGraph is the absolute separation of Fact and Inference. The Deterministic Compiler handles the Facts.
- ABI is Truth: The compiler prioritizes verified ABIs above all other data sources.
- Dependency Tracing: It scans constructors and immutable public variables to determine what other contracts this protocol relies on.
- Role Identification: It statically analyzes
onlyOwner,hasRole, and standard modifiers to build an authorization map.
The Semantic Engine
While structural data is perfect for computers, AI agents and humans need context. The Semantic Engine provides this layer while adhering to strict safety rules.
- Cannot invent blockchain facts
- Cannot guess a variable type
- Cannot perform security audits
- Cannot calculate confidence scores
- Summarize the protocol's goal
- Group related functions (e.g. "Liquidation")
- Explain what a transaction calldata intends
- Provide integration notes for developers
* Note on Confidence: Confidence scores are computed deterministically. The LLM is forbidden from assigning its own confidence levels.
The Protocol Graph Schema
The final output of the pipeline is a standardized JSON schema representing the ProtocolGraph.
data_object Metadata
Core identification strings, proxy configurations, and compilation states.
"metadata": {
"protocol_name": "Lending Vault",
"contract_address": "0x42...",
"compiler_version": "1.0",
"is_proxy": true,
"implementation": "0xc0d3..."
}
account_tree Structural (Deterministic)
The absolute truth extracted from the ABI. Guaranteed to match the on-chain bytecode.
"structural": {
"roles": ["Owner", "Guardian", "Operator"],
"dependencies": [
{ "target": "0xabc...", "type": "Oracle" }
],
"events": ["Deposit", "Withdraw", "Liquidate"],
"functions": 24
}
psychology Semantic & Security (AI Layer)
Inferred human-readable context layered safely on top of the structure.
"semantic": {
"intent": "Manages collateralized debt positions...",
"user_goal": "Deposit USDC to borrow synthetic assets."
},
"security": {
"guardrails": ["Requires Oracle heartbeat within 1hr"],
"privileged_functions": ["pause()", "upgradeTo()"]
}
SDK Integration (Developer Preview)
The programmatic SDK is fully developed and exported directly from the published NPM package. You can install it and import the client class to build custom programmatic integrations:
import { HashGraphClient } from "hashgraph-mcp"; // Initialize client const client = new HashGraphClient({ rpcUrl: process.env.RPC_URL, cacheMode: "HIT_OR_COMPILE" }); // Fetch the full compiled graph const graph = await client.getProtocolGraph( "0x4200000000000000000000000000000000000015" ); console.log("Roles detected:", graph.structural.roles); console.log("AI Summary:", graph.semantic.intent);
MCP Server (For AI Agents)
The Model Context Protocol (MCP) server allows AI agents like Claude Desktop or Cursor to directly interact with the deterministic HashGraph compiler without you having to write any code.
Claude Desktop Setup
Add this to your ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"hashgraph": {
"command": "npx",
"args": ["-y", "hashgraph-mcp"]
}
}
}
Restart Claude, and you can now ask Claude questions like: "Analyze contract 0x... and tell me what dependencies it has."
Available Tools (Exposed via MCP)
info Concept Clarification: Tools vs. Functions
It is easy to confuse MCP Server Tools with Contract ABI Functions:
The APIs exposed by the HashGraph MCP server to AI agents (e.g. get_protocol_graph, explain_transaction).
The smart contract functions written in Solidity and deployed on-chain (e.g. transfer, setOwner) that HashGraph compiles.
| Tool Name | Parameters | Description |
|---|---|---|
| get_protocol_graph | address | Compiles a smart contract address into a structured JSON graph containing roles, dependencies, events, and intent. |
| get_contract_summary | address | Returns a lightweight structural and metadata overview of a contract. |
| explain_transaction | address, calldata | Decodes raw transaction calldata and evaluates its safety based on the compiled deterministic graph. |
| search_protocol | address, query | Searches the cached protocol graphs for specific privileges, standard interfaces, or variables. |
| simulate_transaction | to, data, from?, value? | Simulates a transaction against the blockchain to see its outcome without writing state. |
| read_contract | address, data | Reads state variables or evaluates view functions directly from the contract. |
| get_source_code | address | Fetches fully resolved, unflattened Solidity source code for verified contracts. |
| lookup_graph_attestation | address | Checks the on-chain HashKey Mainnet attestation registry for a protocol graph hash. |
| register_protocol_graph | address, graphHash, metadataURI | Registers a deterministic protocol graph hash to the mainnet registry (gated by default). |
Interactive Examples
The best way to understand the Protocol Graph is to compile one yourself.
HashGraph Explorer
Paste any HashKey Chain contract address into the Explorer to watch the Deterministic Compiler pipeline in real time.