openttt 0.2.11 → 0.2.12
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 +99 -284
- package/package.json +9 -12
- package/dist/dynamic_fee.d.ts +0 -75
- package/dist/dynamic_fee.js +0 -254
- package/dist/http_client.d.ts +0 -98
- package/dist/http_client.js +0 -252
- package/dist/integrity_client.d.ts +0 -41
- package/dist/integrity_client.js +0 -122
- package/dist/osnma_source.d.ts +0 -82
- package/dist/osnma_source.js +0 -169
- package/dist/protocol_fee.d.ts +0 -72
- package/dist/protocol_fee.js +0 -199
- package/dist/revenue_tiers.d.ts +0 -36
- package/dist/revenue_tiers.js +0 -83
- package/dist/x402_enforcer.d.ts +0 -44
- package/dist/x402_enforcer.js +0 -92
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
|
-
**
|
|
5
|
+
**Cryptographic Proof-of-Time for Distributed Systems** — TLS-grade time verification without trust assumptions.
|
|
6
6
|
|
|
7
|
-
OpenTTT brings
|
|
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
|
[](https://www.npmjs.com/package/openttt)
|
|
10
10
|
[](LICENSE)
|
|
11
11
|
[](https://github.com/Helm-Protocol/OpenTTT/actions/workflows/ci.yml)
|
|
12
|
-
[](https://codecov.io/gh/Helm-Protocol/OpenTTT)
|
|
13
12
|
[]()
|
|
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
|
|
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
|
-
| |
|
|
24
|
+
| | Conventional NTP | OpenTTT |
|
|
28
25
|
|---|---|---|
|
|
29
|
-
| **Mechanism** |
|
|
30
|
-
| **
|
|
31
|
-
| **
|
|
32
|
-
| **
|
|
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**:
|
|
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
|
|
37
|
-
- **Dishonest
|
|
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
|
|
37
|
+
No governance vote. No slashing committee. Cheating is simply bad engineering.
|
|
40
38
|
|
|
41
39
|
---
|
|
42
40
|
|
|
43
|
-
##
|
|
44
|
-
|
|
45
|
-
A common question: *"Google Roughtime already solves timestamp verification — why do we need OpenTTT?"*
|
|
41
|
+
## Product Suite
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
OpenTTT is the open-source core of the Helm Protocol product family. The full suite:
|
|
48
44
|
|
|
49
|
-
| |
|
|
45
|
+
| Product | Description | Key Metric |
|
|
50
46
|
|---|---|---|
|
|
51
|
-
| **
|
|
52
|
-
| **
|
|
53
|
-
| **
|
|
54
|
-
| **
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
> Roughtime proves time fraud happened. OpenTTT makes time fraud economically irrational before it can happen.
|
|
54
|
+
## Use Cases
|
|
59
55
|
|
|
60
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
###
|
|
69
|
+
### Proof-of-Time in 30 Seconds — HTTPS 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
|
|
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.
|
|
84
83
|
|
|
85
|
-
###
|
|
84
|
+
### Server Mode — Continuous PoT Stream
|
|
86
85
|
|
|
87
86
|
```typescript
|
|
88
87
|
import { TTTClient } from "openttt";
|
|
89
88
|
|
|
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
|
|
99
|
-
|
|
100
|
-
OpenTTT is designed around progressive disclosure. Start simple, add control as you need it.
|
|
101
|
-
|
|
102
|
-
### Level 1 -- Just Works
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
import { TTTClient } from "openttt";
|
|
106
|
-
|
|
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
95
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
221
|
-
ttt.onAlert((alert) => {
|
|
222
|
-
// Send to PagerDuty, Slack, Telegram, etc.
|
|
223
|
-
console.error(`[OpenTTT Alert] ${alert}`);
|
|
224
|
-
});
|
|
116
|
+
## Architecture
|
|
225
117
|
|
|
226
|
-
|
|
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)
|
|
227
130
|
```
|
|
228
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
|
|
149
|
+
|
|
229
150
|
---
|
|
230
151
|
|
|
231
|
-
##
|
|
152
|
+
## IETF Draft
|
|
232
153
|
|
|
233
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `ttt.
|
|
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.
|
|
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
|
|
279
|
-
| `generateProofOfTime()` | Generate a verifiable
|
|
280
|
-
| `verifyProofOfTime(pot)` | Verify
|
|
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
|
|
290
|
-
| `GrgPipeline.processInverse(shards, length)` | Decode
|
|
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`
|
|
194
|
+
All SDK errors extend `TTTBaseError` with three actionable fields:
|
|
350
195
|
|
|
351
196
|
```typescript
|
|
352
|
-
import {
|
|
197
|
+
import { TTTTimeSynthesisError } from "openttt";
|
|
353
198
|
|
|
354
199
|
try {
|
|
355
|
-
const
|
|
356
|
-
signer: { type: "privateKey", envVar: "MISSING_VAR" },
|
|
357
|
-
});
|
|
200
|
+
const pot = await client.generatePoT();
|
|
358
201
|
} catch (e) {
|
|
359
|
-
if (e instanceof
|
|
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
|
|
212
|
+
| `TTTConfigError` | SDK configuration |
|
|
370
213
|
| `TTTSignerError` | Signer acquisition or usage |
|
|
371
|
-
| `TTTNetworkError` |
|
|
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
|
|
223
|
+
- Network access to NTP sources (UDP 123 outbound or HTTPS fallback)
|
|
401
224
|
|
|
402
|
-
**Optional peer dependencies
|
|
225
|
+
**Optional peer dependencies:**
|
|
403
226
|
|
|
404
227
|
| Package | Required for |
|
|
405
228
|
|---|---|
|
|
@@ -410,31 +233,23 @@ await ttt.destroy();
|
|
|
410
233
|
|
|
411
234
|
## License
|
|
412
235
|
|
|
413
|
-
[Business Source License 1.1](LICENSE)
|
|
414
|
-
|
|
415
|
-
Copyright 2026 Helm Protocol.
|
|
236
|
+
[Business Source License 1.1](LICENSE) — Copyright 2026 Helm Protocol.
|
|
416
237
|
|
|
417
238
|
---
|
|
418
239
|
|
|
419
|
-
##
|
|
420
|
-
|
|
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
|
|
240
|
+
## Links
|
|
427
241
|
|
|
428
|
-
[
|
|
242
|
+
- [IETF Draft: draft-helmprotocol-tttps-00](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) — Protocol specification
|
|
243
|
+
- [Helm Protocol GitHub](https://github.com/Helm-Protocol) — Organization and repositories
|
|
429
244
|
|
|
430
245
|
---
|
|
431
246
|
|
|
432
247
|
## Contributing
|
|
433
248
|
|
|
434
|
-
|
|
249
|
+
Bug reports, feature requests, and pull requests are welcome.
|
|
435
250
|
|
|
436
251
|
- **Bug reports**: Open an issue with a minimal reproduction case.
|
|
437
252
|
- **Feature requests**: Open an issue describing the use case and expected behavior.
|
|
438
|
-
- **Pull requests**: Fork
|
|
253
|
+
- **Pull requests**: Fork, make changes, ensure all tests pass (`npm test`), open a PR against `main`.
|
|
439
254
|
|
|
440
|
-
For significant changes,
|
|
255
|
+
For significant changes, open an issue first to discuss the approach.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openttt",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "OpenTTT
|
|
3
|
+
"version": "0.2.12",
|
|
4
|
+
"description": "OpenTTT — TLS-grade transaction ordering for DeFi. Time + Logic + Sync.",
|
|
5
5
|
"license": "BSL-1.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,8 +31,6 @@
|
|
|
31
31
|
"files": [
|
|
32
32
|
"dist/ct_log.js",
|
|
33
33
|
"dist/ct_log.d.ts",
|
|
34
|
-
"dist/dynamic_fee.js",
|
|
35
|
-
"dist/dynamic_fee.d.ts",
|
|
36
34
|
"dist/errors.js",
|
|
37
35
|
"dist/errors.d.ts",
|
|
38
36
|
"dist/evm_connector.js",
|
|
@@ -53,10 +51,6 @@
|
|
|
53
51
|
"dist/pool_registry.d.ts",
|
|
54
52
|
"dist/pot_signer.js",
|
|
55
53
|
"dist/pot_signer.d.ts",
|
|
56
|
-
"dist/protocol_fee.js",
|
|
57
|
-
"dist/protocol_fee.d.ts",
|
|
58
|
-
"dist/revenue_tiers.js",
|
|
59
|
-
"dist/revenue_tiers.d.ts",
|
|
60
54
|
"dist/signer.js",
|
|
61
55
|
"dist/signer.d.ts",
|
|
62
56
|
"dist/time_synthesis.js",
|
|
@@ -67,8 +61,6 @@
|
|
|
67
61
|
"dist/types.d.ts",
|
|
68
62
|
"dist/v4_hook.js",
|
|
69
63
|
"dist/v4_hook.d.ts",
|
|
70
|
-
"dist/x402_enforcer.js",
|
|
71
|
-
"dist/x402_enforcer.d.ts",
|
|
72
64
|
"README.md"
|
|
73
65
|
],
|
|
74
66
|
"scripts": {
|
|
@@ -104,5 +96,10 @@
|
|
|
104
96
|
"ts-jest": "^29.1.2",
|
|
105
97
|
"typescript": "^5.3.3"
|
|
106
98
|
},
|
|
107
|
-
"mcpName": "io.github.Helm-Protocol/openttt-pot"
|
|
108
|
-
|
|
99
|
+
"mcpName": "io.github.Helm-Protocol/openttt-pot",
|
|
100
|
+
"overrides": {
|
|
101
|
+
"defu": ">=6.1.4",
|
|
102
|
+
"picomatch": ">=4.0.2",
|
|
103
|
+
"handlebars": ">=4.7.9"
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dist/dynamic_fee.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export declare const TIER_USD_MICRO: Record<string, bigint>;
|
|
2
|
-
export declare const FEE_TIERS: {
|
|
3
|
-
BOOTSTRAP: {
|
|
4
|
-
mintFee: bigint;
|
|
5
|
-
burnFee: bigint;
|
|
6
|
-
threshold: bigint;
|
|
7
|
-
};
|
|
8
|
-
GROWTH: {
|
|
9
|
-
mintFee: bigint;
|
|
10
|
-
burnFee: bigint;
|
|
11
|
-
threshold: bigint;
|
|
12
|
-
};
|
|
13
|
-
MATURE: {
|
|
14
|
-
mintFee: bigint;
|
|
15
|
-
burnFee: bigint;
|
|
16
|
-
threshold: bigint;
|
|
17
|
-
};
|
|
18
|
-
PREMIUM: {
|
|
19
|
-
mintFee: bigint;
|
|
20
|
-
burnFee: bigint;
|
|
21
|
-
threshold: bigint;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export interface FeeCalculation {
|
|
25
|
-
tttAmount: bigint;
|
|
26
|
-
protocolFeeUsd: bigint;
|
|
27
|
-
feeToken: string;
|
|
28
|
-
feeTokenAddress: string;
|
|
29
|
-
clientNet: bigint;
|
|
30
|
-
tttPriceUsd: bigint;
|
|
31
|
-
usdCost: bigint;
|
|
32
|
-
feeRateMint: bigint;
|
|
33
|
-
feeRateBurn: bigint;
|
|
34
|
-
tier: string;
|
|
35
|
-
}
|
|
36
|
-
export interface PriceOracleConfig {
|
|
37
|
-
poolAddress?: string;
|
|
38
|
-
chainlinkFeed?: string;
|
|
39
|
-
cacheDurationMs: number;
|
|
40
|
-
fallbackPriceUsd: bigint;
|
|
41
|
-
}
|
|
42
|
-
export declare class DynamicFeeEngine {
|
|
43
|
-
private priceCache;
|
|
44
|
-
private provider;
|
|
45
|
-
private rpcUrls;
|
|
46
|
-
private config;
|
|
47
|
-
private warnedSpotPrice;
|
|
48
|
-
private static readonly RECOMMENDED_MAX_CACHE_MS;
|
|
49
|
-
constructor(config: PriceOracleConfig);
|
|
50
|
-
/**
|
|
51
|
-
* Connect to an RPC provider. Accepts a single URL or an array of URLs
|
|
52
|
-
* for multi-RPC fallback. On connection failure, the next URL is tried.
|
|
53
|
-
*/
|
|
54
|
-
connect(rpcUrl: string | string[]): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Iterate through stored RPC URLs and connect to the first one that succeeds.
|
|
57
|
-
* Throws if all URLs fail.
|
|
58
|
-
*/
|
|
59
|
-
private connectToNext;
|
|
60
|
-
getTTTPriceUsd(): Promise<bigint>;
|
|
61
|
-
/**
|
|
62
|
-
* Force-invalidate price cache -- call when immediate price refresh is needed.
|
|
63
|
-
*/
|
|
64
|
-
invalidateCache(): void;
|
|
65
|
-
private fetchUniswapPrice;
|
|
66
|
-
private fetchChainlinkPrice;
|
|
67
|
-
getFeeRate(tttPriceUsd: bigint): {
|
|
68
|
-
mintFee: bigint;
|
|
69
|
-
burnFee: bigint;
|
|
70
|
-
phase: string;
|
|
71
|
-
};
|
|
72
|
-
calculateMintFee(tier: string, tickCount?: number, feeToken?: string, feeTokenAddress?: string): Promise<FeeCalculation>;
|
|
73
|
-
calculateBurnFee(tier: string, tickCount?: number, feeToken?: string, feeTokenAddress?: string): Promise<FeeCalculation>;
|
|
74
|
-
calculateEmergencyMintFee(tier: string, tickCount?: number): Promise<FeeCalculation>;
|
|
75
|
-
}
|