openttt 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,18 +2,15 @@
2
2
 
3
3
  > **Reference implementation of [draft-helmprotocol-tttps-00](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/)**
4
4
 
5
- **OpenSSL for Transaction Ordering** -- TLS-grade Proof of Time for DeFi.
5
+ **Cryptographic Proof-of-Time for Distributed Systems** TLS-grade time verification without trust assumptions.
6
6
 
7
- OpenTTT brings cryptographic time verification to blockchain transaction ordering. Where TLS made HTTP trustworthy, OpenTTT makes transaction sequencing verifiable. No trust assumptions. No gentleman's agreements. Physics.
7
+ OpenTTT brings verifiable, Byzantine-fault-tolerant timestamping to any distributed system. Where TLS made HTTP trustworthy, OpenTTT makes ordering and sequencing verifiable. No trust assumptions. No gentleman's agreements. Physics.
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/openttt)](https://www.npmjs.com/package/openttt)
10
10
  [![License: BSL-1.1](https://img.shields.io/badge/License-BSL--1.1-blue.svg)](LICENSE)
11
11
  [![CI](https://github.com/Helm-Protocol/OpenTTT/actions/workflows/ci.yml/badge.svg)](https://github.com/Helm-Protocol/OpenTTT/actions/workflows/ci.yml)
12
- [![codecov](https://codecov.io/gh/Helm-Protocol/OpenTTT/branch/main/graph/badge.svg)](https://codecov.io/gh/Helm-Protocol/OpenTTT)
13
12
  [![Tests](https://img.shields.io/badge/tests-386%20passing%20%C2%B7%2032%20suites-brightgreen)]()
14
13
 
15
- > If this project is useful to you, please [star it on GitHub](https://github.com/Helm-Protocol/OpenTTT) — it helps others find it.
16
-
17
14
  ```
18
15
  npm install openttt
19
16
  ```
@@ -22,52 +19,54 @@ npm install openttt
22
19
 
23
20
  ## Why OpenTTT
24
21
 
25
- Current MEV protection relies on **trust**: builders promise fair ordering, protocols ask nicely, and everyone hopes for the best. Flashbots asks builders to behave. OpenTTT proves whether they did.
22
+ Current distributed systems rely on **trust** for ordering: services promise fair sequencing, protocols ask nicely, and everyone hopes for the best. OpenTTT proves whether ordering was respected cryptographically, without a trusted third party.
26
23
 
27
- | | Flashbots | OpenTTT |
24
+ | | Conventional NTP | OpenTTT |
28
25
  |---|---|---|
29
- | **Mechanism** | Social contract (request) | Physical verification (proof) |
30
- | **Enforcement** | Reputation, exclusion | Economic natural selection |
31
- | **Bad actors** | Must be identified and removed | Naturally unprofitable, self-selecting out |
32
- | **Time source** | Block timestamp (miner-controlled) | Multi-source NTP synthesis (NIST, Google, Apple) |
26
+ | **Mechanism** | Single-source timestamp | Multi-source synthesized Proof-of-Time |
27
+ | **Verification** | Trust the server | Cryptographic multi-anchor proof |
28
+ | **Attack detection** | None | 13 Byzantine attack types detected |
29
+ | **Enforcement** | Audit after the fact | Real-time rejection at ingestion |
30
+ | **Time sources** | One NTP server | NIST + Apple + Google + Cloudflare (parallel) |
33
31
 
34
- **The core insight**: Rollups generate precise timestamps and deliver them to builders with a receipt. The Adaptive GRG pipeline then verifies whether the builder respected that ordering:
32
+ **The core insight**: Honest participants receive a Proof-of-Time receipt. A multi-layer data integrity pipeline then verifies whether ordering was respected:
35
33
 
36
- - **Honest builder**: Sequence matches -> **Turbo mode** (50ms verification) -> faster -> more profitable
37
- - **Dishonest builder**: Sequence mismatch -> **Full mode** (127ms verification) -> slower -> less profitable -> leaves
34
+ - **Honest node**: Sequence matches **Turbo mode** (fast verification path) lower latency more efficient
35
+ - **Dishonest node**: Sequence mismatch **Full mode** (complete verification path) higher overhead naturally exits
38
36
 
39
- No governance vote. No slashing committee. Cheating is simply bad business.
37
+ No governance vote. No slashing committee. Cheating is simply bad engineering.
40
38
 
41
39
  ---
42
40
 
43
- ## Why OpenTTT, not Google Roughtime?
44
-
45
- A common question: *"Google Roughtime already solves timestamp verification — why do we need OpenTTT?"*
41
+ ## Product Suite
46
42
 
47
- The answer: **Roughtime and OpenTTT operate at completely different points in the lifecycle.**
43
+ OpenTTT is the open-source core of the Helm Protocol product family. The full suite:
48
44
 
49
- | | Google Roughtime | OpenTTT |
45
+ | Product | Description | Key Metric |
50
46
  |---|---|---|
51
- | **When it acts** | After block finalization | Before fork transition is applied |
52
- | **What it does** | Cryptographically proves a timestamp was wrong *after the fact* | Rejects the block *before* it enters chain state |
53
- | **Enforcement** | Audit trail only the bad block is already finalized | Block is invalid on nodes running the hook |
54
- | **Economic effect** | None requires social/legal follow-up | Validator MEV from timestamp drift → 0 as adoption grows |
55
- | **Use case** | Security auditing, forensics | Real-time enforcement at ingestion |
47
+ | **OpenTTT / TTTPS** | Byzantine Audit API cryptographic Proof-of-Time with 13-attack detection | IETF Draft |
48
+ | **HYDRA-KV** | LLM inference KV cache accelerator distributed prefill/decode separation | 3.20× compression, 95.6% dedup |
49
+ | **HYDRA-CDN** | Edge delivery with GapVec5 routing and erasure-coded resilience | 30% loss tolerance |
50
+ | **HYDRA-AUDIT** | Infrastructure audit with Prometheus, JSON-LD, and Grafana integration | TRAI/CERT-In compatible |
51
+
52
+ ---
56
53
 
57
- **In one sentence:**
58
- > Roughtime proves time fraud happened. OpenTTT makes time fraud economically irrational before it can happen.
54
+ ## Use Cases
59
55
 
60
- Roughtime is a valuable audit tool. OpenTTT is an enforcement layer. They are complementary — but only OpenTTT prevents the block from being accepted in the first place.
56
+ ### LLM Inference Acceleration (HYDRA-KV)
57
+ KV cache transfer between prefill and decode nodes becomes a bottleneck at scale. HYDRA-KV uses TTTPS timestamps to sequence and audit cache chunks, combined with a multi-layer compression pipeline that achieves 3.20× reduction and 95.6% deduplication.
61
58
 
62
- ### The game-theoretic guarantee
59
+ ### Resilient Edge Delivery (HYDRA-CDN)
60
+ High-loss network environments (satellite, mobile edge, cross-border) require delivery guarantees that standard CDN protocols cannot provide. HYDRA-CDN uses GapVec5 adaptive routing and erasure coding to tolerate 30% packet loss while maintaining per-chunk TTTPS audit seals.
63
61
 
64
- With OpenTTT hooks active on validator nodes, a validator who drifts their timestamp by X seconds to capture MEV will have their block rejected by hook-enabled nodes. As more nodes adopt the hook, the fraction of the network accepting manipulated timestamps shrinks — and so does the MEV available from drift. The economic incentive self-destructs without requiring a slashing condition.
62
+ ### Byzantine Audit (TTTPS)
63
+ Any distributed system that needs verifiable ordering — financial infrastructure, IoT sensor networks, compliance-regulated APIs — can embed TTTPS to produce tamper-evident Proof-of-Time receipts. 13 Byzantine attack patterns are detected and rejected in real time.
65
64
 
66
65
  ---
67
66
 
68
67
  ## Quick Start
69
68
 
70
- ### Try it in 30 secondsNo ETH, No Wallet
69
+ ### Proof-of-Time in 30 SecondsHTTPS Only, No Setup
71
70
 
72
71
  ```typescript
73
72
  import { HttpOnlyClient } from "openttt";
@@ -80,175 +79,83 @@ const valid = client.verifyPoT(pot);
80
79
  console.log("Valid:", valid); // true
81
80
  ```
82
81
 
83
- No blockchain. No wallet. No gas fees. Just verified time from 4 independent HTTPS sources (NIST, Apple, Google, Cloudflare). Start here, upgrade to on-chain when ready.
84
-
85
- ### On-Chain Mode (Full Power)
86
-
87
- ```typescript
88
- import { TTTClient } from "openttt";
89
-
90
- const ttt = await TTTClient.forBase({ privateKey: process.env.OPERATOR_PK! });
91
- ttt.startAutoMint();
92
- ```
93
-
94
- Connects to Base, synthesizes time from atomic clock sources, and mints Proof-of-Time tokens on-chain.
95
-
96
- ---
97
-
98
- ## Progressive Disclosure
82
+ No infrastructure required. Four independent HTTPS time sources (NIST, Apple, Google, Cloudflare) are queried in parallel. The synthesized median produces a confidence-scored Proof-of-Time immediately.
99
83
 
100
- OpenTTT is designed around progressive disclosure. Start simple, add control as you need it.
101
-
102
- ### Level 1 -- Just Works
84
+ ### Server Mode Continuous PoT Stream
103
85
 
104
86
  ```typescript
105
87
  import { TTTClient } from "openttt";
106
88
 
107
- const ttt = await TTTClient.forBase({ privateKey: process.env.OPERATOR_PK! });
108
- ttt.startAutoMint();
109
- ```
110
-
111
- ### Level 2 -- Custom Network and Tier
112
-
113
- ```typescript
114
- const ttt = await TTTClient.forSepolia({
115
- privateKey: process.env.OPERATOR_PK!,
116
- rpcUrl: "https://my-rpc.example.com",
117
- tier: "T2_slot",
118
- });
119
- ttt.startAutoMint();
120
- ```
121
-
122
- ### Level 3 -- Full Control
123
-
124
- ```typescript
125
89
  const ttt = await TTTClient.create({
126
- signer: {
127
- type: "turnkey",
128
- apiBaseUrl: "https://api.turnkey.com",
129
- organizationId: "org-...",
130
- privateKeyId: "pk-...",
131
- apiPublicKey: "...",
132
- apiPrivateKey: "...",
133
- },
134
- network: "base",
135
- tier: "T1_block",
136
- contractAddress: "0x...",
137
- poolAddress: "0x...",
138
90
  timeSources: ["nist", "google", "cloudflare", "apple"],
139
- protocolFeeRate: 0.05,
140
91
  enableGracefulShutdown: true,
141
92
  });
142
93
 
143
94
  ttt.startAutoMint();
144
- ```
145
-
146
- ---
147
95
 
148
- ## Signer Options
149
-
150
- OpenTTT abstracts away signer complexity. Use a raw private key for development, TEE-backed keys for production, or cloud HSMs for institutional deployments.
151
-
152
- | Type | Use Case | Config |
153
- |---|---|---|
154
- | `privateKey` | Development, small operators | `{ type: "privateKey", key: "0x..." }` or `{ type: "privateKey", envVar: "OPERATOR_PK" }` |
155
- | `turnkey` | Production, TEE-backed institutional custody | `{ type: "turnkey", apiBaseUrl, organizationId, privateKeyId, apiPublicKey, apiPrivateKey }` |
156
- | `privy` | Embedded wallets, consumer-facing apps (coming soon) | `{ type: "privy", appId, appSecret }` |
157
- | `kms` | Cloud HSM (AWS KMS or GCP Cloud KMS) | `{ type: "kms", provider: "aws"\|"gcp", keyId, ... }` |
158
-
159
- **AWS KMS** requires `@aws-sdk/client-kms`. **GCP KMS** requires `@google-cloud/kms`. Both are optional peer dependencies -- install only what you use.
160
-
161
- ---
162
-
163
- ## Tiers
164
-
165
- Tiers control the minting interval. Choose based on your protocol's ordering resolution requirements.
166
-
167
- | Tier | Interval | Use Case |
168
- |---|---|---|
169
- | `T0_epoch` | 6.4 minutes | Epoch-level ordering (validator sets, beacon chain) |
170
- | `T1_block` | 2 seconds | Block-level ordering on Base L2 **(default)** |
171
- | `T2_slot` | 12 seconds | Slot-level ordering on Ethereum L1 |
172
- | `T3_micro` | 100 milliseconds | High-frequency ordering (IoT, sub-block) |
173
-
174
- ```typescript
175
- const ttt = await TTTClient.forBase({
176
- signer: { type: "privateKey", envVar: "OPERATOR_PK" },
177
- tier: "T2_slot",
96
+ ttt.onAlert((alert) => {
97
+ // Route to PagerDuty, Grafana, Telegram, etc.
98
+ console.error(`[OpenTTT Alert] ${alert}`);
178
99
  });
179
100
  ```
180
101
 
181
- ---
182
-
183
- ## Health Monitoring
184
-
185
- Production deployments need observability. `getHealth()` returns a comprehensive status object covering connectivity, balance, and mint performance.
102
+ ### Health Monitoring
186
103
 
187
104
  ```typescript
188
105
  const health = await ttt.getHealth();
189
-
190
- console.log(health);
191
106
  // {
192
107
  // healthy: true,
193
- // checks: {
194
- // initialized: true,
195
- // rpcConnected: true,
196
- // signerAvailable: true,
197
- // balanceSufficient: true,
198
- // ntpSourcesOk: true
199
- // },
200
- // metrics: {
201
- // mintCount: 142,
202
- // mintFailures: 0,
203
- // successRate: 1.0,
204
- // totalFeesPaid: "71000000000000",
205
- // avgMintLatencyMs: 1847,
206
- // lastMintAt: "2026-03-14T10:30:00.000Z",
207
- // uptimeMs: 86400000
208
- // },
108
+ // checks: { ntpSourcesOk: true, signerAvailable: true, ... },
109
+ // metrics: { mintCount: 142, successRate: 1.0, avgMintLatencyMs: 1847 },
209
110
  // alerts: []
210
111
  // }
211
112
  ```
212
113
 
213
- **Alerts** are emitted automatically when:
214
- - RPC connection is lost
215
- - ETH balance drops below threshold (default: 0.01 ETH)
216
- - Mint success rate falls below 80%
217
-
218
- Register a callback for real-time alerting:
114
+ ---
219
115
 
220
- ```typescript
221
- ttt.onAlert((alert) => {
222
- // Send to PagerDuty, Slack, Telegram, etc.
223
- console.error(`[OpenTTT Alert] ${alert}`);
224
- });
116
+ ## Architecture
225
117
 
226
- ttt.setMinBalance(ethers.parseEther("0.05")); // Custom threshold
227
118
  ```
119
+ TTTClient (entry point)
120
+ |-- AutoMintEngine Continuous PoT generation loop
121
+ | |-- TimeSynthesis Multi-source NTP median synthesis
122
+ | | |-- NIST time.nist.gov (US national standard)
123
+ | | |-- Google time.google.com
124
+ | | |-- Apple time.apple.com
125
+ | | '-- Cloudflare time.cloudflare.com
126
+ | '-- GRG Pipeline Multi-layer data integrity (proprietary)
127
+ |-- AdaptiveSwitch TURBO / FULL verification mode state machine
128
+ |-- ByzantineDetector 13-pattern attack classifier
129
+ '-- Signer Abstraction PrivateKey | KMS (AWS / GCP)
130
+ ```
131
+
132
+ ### Time Synthesis
133
+
134
+ OpenTTT queries multiple atomic clock-synchronized sources in parallel and produces a median-synthesized timestamp with confidence scoring. All readings must fall within a stratum-dependent tolerance of the synthesized median, or the Proof of Time is rejected. Single-source operation triggers a degraded-confidence warning.
135
+
136
+ ### GRG Pipeline
137
+
138
+ GRG is a multi-layer data integrity pipeline that protects PoT payloads — analogous to how the TLS record protocol protects HTTP payloads. It provides compression, erasure coding, and error correction in a single pass, producing verifiable shards that can be independently validated and reconstructed.
139
+
140
+ > Implementation details are proprietary. See the [IETF Draft](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) for the abstract specification.
141
+
142
+ ### Adaptive Mode Switching
143
+
144
+ The enforcement mechanism uses a sliding-window match rate with hysteresis:
145
+
146
+ - **Entry to Turbo**: high ordering match rate over a sustained window
147
+ - **Integrity failure in Turbo**: exponential backoff penalty
148
+ - **Design intent**: hard to earn trust, easy to lose it
228
149
 
229
150
  ---
230
151
 
231
- ## Networks
152
+ ## IETF Draft
232
153
 
233
- | Network | Chain ID | Factory Method |
234
- |---|---|---|
235
- | Base Mainnet | 8453 | `TTTClient.forBase(config)` |
236
- | Base Sepolia | 84532 | `TTTClient.forSepolia(config)` |
154
+ OpenTTT implements **draft-helmprotocol-tttps-00** (TTTPS TLS-grade Time Token Protocol Stack).
237
155
 
238
- Custom networks can be provided via the `network` field in `TTTClient.create()`:
156
+ > **Abstract**: This document specifies TTTPS, a protocol for generating and verifying cryptographic Proof-of-Time (PoT) tokens using multiple independent time sources. TTTPS provides Byzantine fault tolerance against timestamp manipulation, supports 13 categories of time-based attacks, and is designed for integration into existing transport-layer security stacks without requiring changes to application protocols.
239
157
 
240
- ```typescript
241
- const ttt = await TTTClient.create({
242
- signer: { type: "privateKey", envVar: "OPERATOR_PK" },
243
- network: {
244
- chainId: 8453,
245
- rpcUrl: "https://my-custom-rpc.example.com",
246
- tttAddress: "0x...",
247
- protocolFeeAddress: "0x...",
248
- usdcAddress: "0x...",
249
- },
250
- });
251
- ```
158
+ Full draft: [datatracker.ietf.org/doc/draft-helmprotocol-tttps/](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/)
252
159
 
253
160
  ---
254
161
 
@@ -258,105 +165,41 @@ const ttt = await TTTClient.create({
258
165
 
259
166
  | Method | Description |
260
167
  |---|---|
261
- | `TTTClient.create(config)` | Create and initialize a client with full configuration |
262
- | `TTTClient.forBase(config)` | Factory for Base Mainnet (chain ID 8453) |
263
- | `TTTClient.forSepolia(config)` | Factory for Base Sepolia testnet (chain ID 84532) |
264
- | `ttt.startAutoMint()` | Start automatic TimeToken minting at the configured tier interval |
265
- | `ttt.stopAutoMint()` | Stop the auto-mint loop |
266
- | `ttt.getHealth()` | Returns `HealthStatus` with connectivity, balance, and performance checks |
267
- | `ttt.getStatus()` | Returns current tier, mint count, fees paid, and token balances |
268
- | `ttt.listPools()` | List all registered pool addresses |
269
- | `ttt.getPoolStats(address)` | Get mint/burn statistics for a specific pool |
168
+ | `TTTClient.create(config)` | Create and initialize a client |
169
+ | `ttt.startAutoMint()` | Start continuous PoT generation |
170
+ | `ttt.stopAutoMint()` | Stop the generation loop |
171
+ | `ttt.getHealth()` | Returns `HealthStatus` with source connectivity and performance |
270
172
  | `ttt.onAlert(callback)` | Register a callback for health alerts |
271
- | `ttt.setMinBalance(wei)` | Set minimum ETH balance threshold for alerts |
272
- | `ttt.destroy()` | Gracefully shut down: stops minting, unsubscribes events, clears state |
173
+ | `ttt.destroy()` | Graceful shutdown |
273
174
 
274
175
  ### TimeSynthesis
275
176
 
276
177
  | Method | Description |
277
178
  |---|---|
278
- | `synthesize()` | Query all configured NTP sources and return a median-synthesized timestamp |
279
- | `generateProofOfTime()` | Generate a verifiable Proof of Time with source signatures |
280
- | `verifyProofOfTime(pot)` | Verify that all source readings are within tolerance of the median |
281
- | `TimeSynthesis.getOnChainHash(pot)` | Keccak256 hash of a PoT for on-chain submission |
282
- | `TimeSynthesis.serializeToBinary(pot)` | Compact binary serialization for network transport |
283
- | `TimeSynthesis.deserializeFromBinary(buf)` | Deserialize from binary format |
179
+ | `synthesize()` | Query all sources, return median-synthesized timestamp |
180
+ | `generateProofOfTime()` | Generate a verifiable PoT with source signatures |
181
+ | `verifyProofOfTime(pot)` | Verify all readings are within tolerance of the median |
284
182
 
285
183
  ### GrgPipeline
286
184
 
287
185
  | Method | Description |
288
186
  |---|---|
289
- | `GrgPipeline.processForward(data)` | Encode data through the multi-layer integrity pipeline, producing verifiable shards |
290
- | `GrgPipeline.processInverse(shards, length)` | Decode shards back to original data with integrity verification |
291
-
292
- ### AdaptiveSwitch
293
-
294
- | Method | Description |
295
- |---|---|
296
- | `verifyBlock(block, tttRecord)` | Verify block ordering against TTT record; returns `TURBO` or `FULL` mode |
297
- | `getCurrentMode()` | Current adaptive mode |
298
- | `getFeeDiscount()` | Fee discount for current mode (20% in TURBO, 0% in FULL) |
299
-
300
- ---
301
-
302
- ## Architecture
303
-
304
- ```
305
- TTTClient (entry point)
306
- |-- AutoMintEngine Periodic minting loop
307
- | |-- TimeSynthesis NTP multi-source median synthesis (NIST, Google, Apple)
308
- | |-- DynamicFeeEngine Oracle-based pricing
309
- | |-- EVMConnector On-chain mint/burn/events (ethers v6)
310
- | '-- ProtocolFee EIP-712 signed fee collection
311
- |-- AdaptiveSwitch TURBO/FULL mode state machine
312
- |-- GRG Pipeline Multi-layer data integrity (proprietary)
313
- |-- PoolRegistry Multi-pool statistics tracking
314
- '-- Signer Abstraction PrivateKey | Turnkey | Privy | KMS
315
- ```
316
-
317
- ### Data Integrity: GRG Pipeline
318
-
319
- GRG is a multi-layer data integrity pipeline that protects PoT payloads — analogous to how the TLS record protocol protects HTTP payloads. It provides compression, erasure coding, and error correction in a single pass.
320
-
321
- The pipeline produces verifiable shards that can be independently validated and reconstructed, ensuring PoT integrity even under partial data loss.
322
-
323
- > Implementation details are proprietary. See the [IETF Draft](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) for the abstract specification.
324
-
325
- ### Adaptive Mode Switching
326
-
327
- The economic enforcement mechanism uses a sliding window (20 blocks) with hysteresis:
328
-
329
- - **Entry to Turbo**: 95% ordering match rate over 20+ blocks
330
- - **Maintain Turbo**: 85% match rate (relaxed to prevent flapping)
331
- - **Integrity failure in Turbo**: Exponential backoff penalty (20, 40, 80, 160, 320 blocks)
332
-
333
- This asymmetry is deliberate: it is hard to earn trust and easy to lose it.
334
-
335
- ### Time Synthesis
336
-
337
- OpenTTT queries multiple atomic clock-synchronized NTP sources in parallel and produces a median-synthesized timestamp with confidence scoring:
338
-
339
- - **NIST** (time.nist.gov) -- US national standard
340
- - **Apple** (time.apple.com) -- Apple global time service
341
- - **Google** (time.google.com) -- Leap-smeared public NTP
342
-
343
- All readings must fall within a stratum-dependent tolerance of the synthesized median (10ms for stratum 1, 25ms for stratum 2, 50ms for stratum 3+), or the Proof of Time is rejected. Single-source operation triggers a degraded-confidence warning.
187
+ | `GrgPipeline.processForward(data)` | Encode through the multi-layer integrity pipeline |
188
+ | `GrgPipeline.processInverse(shards, length)` | Decode with integrity verification |
344
189
 
345
190
  ---
346
191
 
347
192
  ## Error Handling
348
193
 
349
- All SDK errors extend `TTTBaseError` and include three fields for actionable diagnostics:
194
+ All SDK errors extend `TTTBaseError` with three actionable fields:
350
195
 
351
196
  ```typescript
352
- import { TTTSignerError } from "openttt";
197
+ import { TTTTimeSynthesisError } from "openttt";
353
198
 
354
199
  try {
355
- const ttt = await TTTClient.forBase({
356
- signer: { type: "privateKey", envVar: "MISSING_VAR" },
357
- });
200
+ const pot = await client.generatePoT();
358
201
  } catch (e) {
359
- if (e instanceof TTTSignerError) {
202
+ if (e instanceof TTTTimeSynthesisError) {
360
203
  console.error(e.message); // What happened
361
204
  console.error(e.reason); // Why it happened
362
205
  console.error(e.fix); // How to fix it
@@ -366,30 +209,10 @@ try {
366
209
 
367
210
  | Error Class | Scope |
368
211
  |---|---|
369
- | `TTTConfigError` | SDK or engine configuration |
212
+ | `TTTConfigError` | SDK configuration |
370
213
  | `TTTSignerError` | Signer acquisition or usage |
371
- | `TTTNetworkError` | RPC, chain ID, connectivity |
372
- | `TTTContractError` | Smart contract interaction |
214
+ | `TTTNetworkError` | Connectivity, source availability |
373
215
  | `TTTTimeSynthesisError` | NTP time synthesis failures |
374
- | `TTTFeeError` | Dynamic fee or protocol fee collection |
375
-
376
- ---
377
-
378
- ## Graceful Shutdown
379
-
380
- For long-running services, enable graceful shutdown to cleanly stop minting and release resources on SIGINT:
381
-
382
- ```typescript
383
- const ttt = await TTTClient.create({
384
- signer: { type: "privateKey", envVar: "OPERATOR_PK" },
385
- network: "base",
386
- enableGracefulShutdown: true,
387
- });
388
- ttt.startAutoMint();
389
-
390
- // Or shut down manually at any time:
391
- await ttt.destroy();
392
- ```
393
216
 
394
217
  ---
395
218
 
@@ -397,9 +220,9 @@ await ttt.destroy();
397
220
 
398
221
  - Node.js >= 18
399
222
  - TypeScript >= 5.3 (for development)
400
- - Network access to NTP servers (UDP port 123 outbound)
223
+ - Network access to NTP sources (UDP 123 outbound or HTTPS fallback)
401
224
 
402
- **Optional peer dependencies** (install only what you use):
225
+ **Optional peer dependencies:**
403
226
 
404
227
  | Package | Required for |
405
228
  |---|---|
@@ -408,33 +231,45 @@ await ttt.destroy();
408
231
 
409
232
  ---
410
233
 
411
- ## License
234
+ ## Pricing
412
235
 
413
- [Business Source License 1.1](LICENSE)
236
+ | Tier | Price | Quota | Use Case |
237
+ |---|---|---|---|
238
+ | **FREE** | $0 | 100 calls/day | Non-commercial, research, personal bots (revenue < $10K/yr) |
239
+ | **BOT** | $199/mo | 5M calls · 1K req/s | MEV bots, arbitrage bots |
240
+ | **DEX/LP** | $499/mo | 20M calls + overage | DEX protocols, liquidity providers |
241
+ | **FUND** | $2,000+/mo | Unlimited + MiFIR Art.22c audit log | Hedge funds, OTC desks, prop trading |
414
242
 
415
- Copyright 2026 Helm Protocol.
243
+ API key & commercial licensing: heime.jorgen@proton.me
416
244
 
417
245
  ---
418
246
 
419
- ## Learn More
247
+ ## License
248
+
249
+ BSL-1.1 — free for non-commercial use.
250
+
251
+ **Commercial use** (production bots, hedge funds, prop desks) requires a license.
252
+ → [Pricing](https://github.com/Helm-Protocol/openttt-mcp#pricing)
253
+
254
+ Change Date: 2029-05-28 → Apache 2.0
255
+
256
+ Full license text: [LICENSE](LICENSE) — Copyright 2026 Helm Protocol.
257
+
258
+ ---
420
259
 
421
- - [IETF Draft: draft-helmprotocol-tttps-00](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) — TTTPS Protocol Specification
422
- - [Yellow Paper](https://github.com/Helm-Protocol/OpenTTT/blob/main/YELLOW_PAPER.md) — Technical Deep Dive
423
- - [MCP Server](https://github.com/Helm-Protocol/OpenTTT/tree/main/mcp) — AI Agent Integration (`@helm-protocol/ttt-mcp`)
424
- - [Subgraph (The Graph)](https://api.studio.thegraph.com/query/1744392/openttt-base-sepolia/v0.2.0) — On-chain PoT Data
425
- - [Base Sepolia Contracts](https://sepolia.basescan.org/address/0xde357135cA493e59680182CDE9E1c6A4dA400811) — TTT ERC-1155
426
- - [Helm Protocol](https://github.com/Helm-Protocol) — GitHub Organization
260
+ ## Links
427
261
 
428
- [GitHub](https://github.com/Helm-Protocol/OpenTTT) | Built by [Helm Protocol](https://github.com/Helm-Protocol)
262
+ - [IETF Draft: draft-helmprotocol-tttps-00](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) Protocol specification
263
+ - [Helm Protocol GitHub](https://github.com/Helm-Protocol) — Organization and repositories
429
264
 
430
265
  ---
431
266
 
432
267
  ## Contributing
433
268
 
434
- Contributions are welcome. If you find a bug, have a feature request, or want to improve the documentation, please open an issue or submit a pull request on [GitHub](https://github.com/Helm-Protocol/OpenTTT).
269
+ Bug reports, feature requests, and pull requests are welcome.
435
270
 
436
271
  - **Bug reports**: Open an issue with a minimal reproduction case.
437
272
  - **Feature requests**: Open an issue describing the use case and expected behavior.
438
- - **Pull requests**: Fork the repo, make your changes, ensure all tests pass (`npm test`), and open a PR against `main`.
273
+ - **Pull requests**: Fork, make changes, ensure all tests pass (`npm test`), open a PR against `main`.
439
274
 
440
- For significant changes, please open an issue first to discuss the approach.
275
+ For significant changes, open an issue first to discuss the approach.
@@ -0,0 +1,41 @@
1
+ export declare enum AdaptiveMode {
2
+ TURBO = "TURBO",// 50ms — Valid sequence, low latency
3
+ FULL = "FULL"
4
+ }
5
+ export interface TTTRecord {
6
+ time: number;
7
+ txOrder: string[];
8
+ grgPayload: Uint8Array[];
9
+ }
10
+ export interface Block {
11
+ timestamp: number;
12
+ txs: string[];
13
+ data: Uint8Array;
14
+ }
15
+ /** Tier-based dynamic tolerance (ms) */
16
+ export declare const TIER_TOLERANCE_MS: Record<string, number>;
17
+ export declare class AdaptiveSwitch {
18
+ private windowSize;
19
+ private turboEntryThreshold;
20
+ private turboMaintainThreshold;
21
+ private history;
22
+ private currentMode;
23
+ private minBlocks;
24
+ private penaltyCooldown;
25
+ private consecutiveFailures;
26
+ private tolerance;
27
+ constructor(options?: {
28
+ tolerance?: number;
29
+ });
30
+ /**
31
+ * Client-side TTT check: timestamp ordering + time delta only.
32
+ * GRG integrity verification is delegated to the server (IntegrityClient).
33
+ */
34
+ verifyBlock(block: Block, tttRecord: TTTRecord, _chainId: number, _poolAddress: string, tier?: string): AdaptiveMode;
35
+ getFeeDiscount(): number;
36
+ getCurrentMode(): AdaptiveMode;
37
+ reset(): void;
38
+ serialize(): string;
39
+ static deserialize(json: string): AdaptiveSwitch;
40
+ private compareTransactionOrder;
41
+ }