Skip to main content

Proof-of-Time tools for LangChain agents — cryptographic temporal attestation for DeFi transactions and general LLM audit-trail timestamping

Project description

OpenTTT LangChain Integration

Problem: DEX swaps get front-run. Your agent can't prove transaction ordering.

Solution: verify_proof_of_time generates cryptographic timestamps from 3+ atomic clock sources (NIST, Google, Apple) and verifies swap ordering on-chain.

Result: Your agent detects MEV attacks in one tool call.

Installation

npm install openttt @langchain/core zod

Quick Start

import { VerifyProofOfTimeTool } from "openttt/integrations/langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createToolCallingAgent, AgentExecutor } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

// 1. Create the tool
const potTool = new VerifyProofOfTimeTool();

// 2. Wire into your agent
const llm = new ChatOpenAI({ model: "gpt-4o" });
const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You are a DeFi security agent. Use verify_proof_of_time to check transaction ordering."],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);

const agent = createToolCallingAgent({ llm, tools: [potTool], prompt });
const executor = new AgentExecutor({ agent, tools: [potTool] });

// 3. Run
const result = await executor.invoke({
  input: "Verify ordering for tx 0xabc123... on Base (chain 8453) pool 0xdef456...",
});

Tool Details

Field Value
Name verify_proof_of_time
Inputs txHash (string), chainId (number), poolAddress (string)
Output JSON with verified, proof (timestamp, confidence, sources), sourceReadings

Configuration

// Custom time sources
const tool = new VerifyProofOfTimeTool({
  timeSources: ["nist", "google", "cloudflare"],
});

What the Proof Contains

{
  "verified": true,
  "proof": {
    "timestamp": "1742000000000000000",
    "uncertainty_ms": 2.5,
    "sources": 3,
    "stratum": 1,
    "confidence": 1.0,
    "nonce": "a1b2c3...",
    "expiresAt": "1742000060000",
    "onChainHash": "0x..."
  },
  "sourceReadings": [
    { "source": "nist", "timestamp": "...", "uncertainty_ms": 1.2 },
    { "source": "apple", "timestamp": "...", "uncertainty_ms": 3.1 },
    { "source": "google", "timestamp": "...", "uncertainty_ms": 2.0 }
  ]
}

How It Works

  1. Queries 3+ independent atomic clock sources simultaneously
  2. Synthesizes a median timestamp with confidence score
  3. Self-verifies cross-source consistency (stratum-adaptive tolerance)
  4. Applies nonce + expiration for replay protection
  5. Computes keccak256 hash for optional on-chain contract verification

Learn More

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_openttt-0.2.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_openttt-0.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_openttt-0.2.0.tar.gz.

File metadata

  • Download URL: langchain_openttt-0.2.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for langchain_openttt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 52ea48cbf0f618faea19e30d22d8b36b3ad8e8de72dfe04d834abd0b9eb9b263
MD5 4e8a0e84bfb4384d3f23462f29aaa100
BLAKE2b-256 e37691d7d688a732b3ea266be522c2780898d471d93e30ee8efbd6be0542ec4d

See more details on using hashes here.

File details

Details for the file langchain_openttt-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_openttt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 106af9b7a299a342d0b18558c02f99fcff82caed08621ed4c7deb3f3155a50af
MD5 15e6818951080f3eb91a6c6bab7e4d42
BLAKE2b-256 ba4991a76871d5a164c54dbe0592f9cb6d203486d3399d1a045bcbe5b6df23cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page