Proof-of-Time tools for LangChain agents — Byzantine-resistant temporal attestation for DeFi transactions
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
- Queries 3+ independent atomic clock sources simultaneously
- Synthesizes a median timestamp with confidence score
- Self-verifies cross-source consistency (stratum-adaptive tolerance)
- Applies nonce + expiration for replay protection
- Computes
keccak256hash for optional on-chain contract verification
Learn More
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_openttt-0.1.0.tar.gz.
File metadata
- Download URL: langchain_openttt-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2c997b31c75e13025239c3feee6ed800bede4678e9372f44e526504fe97f1b7
|
|
| MD5 |
5947630df39c3e5b3cc281f868ef6df9
|
|
| BLAKE2b-256 |
5387eae7f2b5e5ef0f7aed7d97a2d5136edf34835cec954d6957444088439c61
|
File details
Details for the file langchain_openttt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_openttt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c088a06c1911f19c3a21432eb01523b06968937defa75039dbd0cfa75973f4
|
|
| MD5 |
3048124fe9b6dd103fab0c1dee4da158
|
|
| BLAKE2b-256 |
2815565ee9519d00acb2e2b468cd8aea6b50823de44cf3f45ce8931453e669b8
|