TWIX CHAINDevice API
TDAP v0.1 · DEVICE API v0.2.0

Connect physical data
to TWIX proof.

Any meter, gateway, sensor or application that can obtain a reading and sign bytes can submit TDAP records. TWIX does not require manufacturer support.

Ingest endpointPOST /api/ingest.php
AuthenticationEd25519 signature
Record commitmentSHA-256
Anchor networkTWIX Mainnet
THE IMPORTANT PART

No API secret has to live on our server.

The device identity is its Ed25519 public key. The meter or gateway keeps the private key, builds the canonical record, hashes it and signs the raw 32-byte hash. The collector verifies the registered public key, sequence and previous-hash chain before accepting anything.

01Read meterModbus, DLMS/COSEM, MQTT, serial, REST, BACnet or vendor API.
02NormalizeConvert into TDAP canonical JSON.
03SignSHA-256 + Ed25519 on device/gateway.
04IngestPOST the signed envelope.
05AnchorMerkle root gets TWIX block time.
1 · REGISTER DEVICE

Register only the public identity.

In Admin → Devices, create a stable device ID and paste its 32-byte Ed25519 public key as base64url. Choose a visibility policy: public, hash_only (recommended default), or private. Batches are built from one visibility class at a time so a public proof cannot accidentally expose commitments from a restricted batch.

Device ID:  meter:facility-a:main-001
Public key: n2E...base64url...
Adapter:    modbus
Visibility: hash_only
2 · CANONICAL RECORD

Build the exact signed object.

{
  "protocol": "twix-dap/0.1",
  "device_id": "meter:facility-a:main-001",
  "sequence": 1843,
  "schema": "energy.meter.reading/1",
  "measured_at": "2026-08-26T19:30:00Z",
  "previous_hash": "d7ac...",
  "payload": {
    "value": "14832.771",
    "unit": "kWh"
  }
}

Objects are key-sorted recursively, arrays retain order, whitespace is removed, and precision-sensitive decimal measurements are strings. JSON floating-point numbers are rejected by the reference collector.

3 · HASH + SIGN

Domain-separated commitment.

record_hash = SHA-256(
  UTF8("TWIX-DAP-RECORD-v0.1") ||
  0x00 ||
  UTF8(canonical_record_json)
)

signature = Ed25519.sign(device_private_key, raw_32_byte_record_hash)

The private key never appears in the API request.

4 · INGEST

POST the signed envelope.

curl -X POST https://validator.twixchain.com/api/ingest.php \
  -H 'Content-Type: application/json' \
  --data @signed-reading.json
{
  "record": { "...": "canonical TDAP record" },
  "record_hash": "64 lowercase hex characters",
  "signature": "base64url Ed25519 signature"
}

Success returns HTTP 201 with the accepted hash, collector receive time, sequence and visibility. Requests over 64 KiB are rejected. Replay/out-of-order sequence, bad previous hash, bad signature and unknown/expired devices are rejected.

OFF-CHAIN STORAGE

Store the complete envelope anywhere you can afford to keep bytes.

The collector keeps a protected local copy for the reference implementation, but TDAP integrity does not depend on that specific disk. The exact signed envelope can be mirrored to ordinary shared hosting, S3-compatible object storage, Backblaze, a NAS, IPFS or archival media. When the bytes are retrieved later, the record hash, device signature and Merkle proof detect alteration.

Availability and integrity are different problems.

The TWIX anchor preserves the commitment even if one storage host disappears. Verification still requires a surviving copy of the signed record/proof, so important data should be mirrored.

REFERENCE TEST VECTOR

Cross-language implementations can test themselves.

Canonical JSON:
{"device_id":"meter:test:001","measured_at":"2026-08-26T20:00:00Z","payload":{"unit":"kWh","value":"14832.771"},"previous_hash":null,"protocol":"twix-dap/0.1","schema":"energy.meter.reading/1","sequence":1}

TDAP record hash:
3770ad8a5ff06fb05403926524dae336e3d1bf122ecdb145502822ab8ce03798
API REFERENCE

Public endpoints

MethodEndpointPurpose
POST/api/ingest.phpSigned device record ingestion
GET/api/status.phpTWIX + platform status
GET/api/metrics.phpAggregate API health metrics
GET/api/device.php?id=...Device public identity
GET/api/proof.php?hash=...Public proof bundle when visibility permits
GET/api/batch.php?root=...Merkle batch and anchor state
GET/api/openapi.jsonOpenAPI 3.1 definition
METER ADAPTERS

The meter does not need to know TWIX exists.

Modbus TCP / RTU

Read holding/input registers on a local gateway, scale according to meter documentation, then submit TDAP.

DLMS/COSEM

A gateway reads OBIS values, maps them to a TDAP schema and signs locally.

MQTT

Subscribe to a trusted topic, normalize messages and sign them before ingestion.

BACnet

Read building-management points through a gateway and attest selected measurements.

Serial / pulse

A Raspberry Pi/industrial gateway can count or parse local output and become the cryptographic device identity.

Vendor API

Poll a manufacturer/cloud API, preserve its source timestamp and add a gateway signature + collector timestamp.

DOWNLOADABLE CLIENTS

Reference SDKs and integration examples

SECURITY BOUNDARY

Never give a meter access to the validator key.

The meter agent runs as a separate process/user and owns only its device identity. On-chain anchoring uses a dedicated EVM signer. TWIX consensus remains independent if a meter, gateway, storage provider or API client fails.