Developer Documentation

Build AI agents, bots, and applications that trade on Hashlock Markets. Three integration paths, five tools, one unified swap intent API.

Quick start

1. MCP server (Claude, Cursor, Windsurf, VS Code)

Add this block to your MCP client configuration. Works with any MCP-compatible tool including Claude Desktop, Cursor, Windsurf, and VS Code.

{
  "mcpServers": {
    "hashlock": {
      "command": "npx",
      "args": ["-y", "hashlock-mcp-server"]
    }
  }
}

Package: hashlock-mcp-server (npm) · Listed on the MCP Registry

2. Vercel AI SDK (TypeScript / JavaScript)

Import hashlockTools and pass it to generateText from the Vercel AI SDK. Works with any model provider the AI SDK supports — OpenAI, Anthropic, Google, Mistral, Groq, and more.

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { hashlockTools } from 'hashlock-ai-sdk';

const { text } = await generateText({
  model: openai('gpt-4o'),
  tools: hashlockTools(),
  maxSteps: 5,
  prompt: 'Swap 1 ETH for USDC on Ethereum',
});

Package: hashlock-ai-sdk (npm)

3. LangChain (Python)

Import HashlockTools and bind it to any LangChain agent. Works with LCEL chains and the agent executor pattern.

from langchain_hashlock import HashlockTools
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI

tools = HashlockTools()
llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)

executor.invoke({"input": "Swap 1 ETH for USDC on Ethereum"})

Package: langchain-hashlock (PyPI)

Core concepts

Swap intent

An intent expresses what you want to trade: “swap 1 ETH for USDC on Ethereum”. Intents specify the source asset, target asset, amount, chain, and optional constraints (minimum output, deadline). Intents are declarative — you describe the outcome, the protocol decides the path.

Sealed-bid execution

When you commit an intent, verified counterparties submit private bids no one else can see — not even other bidders. The protocol selects the best match based on price and reliability. Because bids are sealed, there is no front-running, no MEV sandwich attacks, and zero slippage.

HTLC atomic settlement

Both legs of the swap are locked into Hash Time-Locked Contracts on their respective chains. A single preimage reveal unlocks both sides simultaneously. If the preimage is never revealed, funds return to the original owners after the timelock. There is no intermediary holding assets and no partial-fill risk.

Supported chains

  • Ethereum mainnet — ETH, ERC-20 tokens, stablecoins, tokenized RWA
  • Bitcoin — native BTC via HTLC script
  • SUI — SUI tokens and Move-based assets

Available agent tools

All three integration paths (MCP, Vercel AI SDK, LangChain) expose the same five tools with identical semantics:

create_intent
Create a new swap intent with asset pair, amount, and target chain.
validate_intent
Validate an intent before submission. Checks asset validity, chain support, and bounds.
commit_intent
Submit a validated intent to the Hashlock network for sealed-bid matching.
explain_intent
Get a human-readable English explanation of what an intent will do.
parse_natural_language
Convert phrases like "swap 1 ETH for USDC" into a structured intent object.

Machine-readable resources

Developer Docs — MCP, Vercel AI SDK, LangChain | Hashlock Markets