JSON-RPC 2.0 server that dynamically exposes Tx3 protocols. Drop a .tii file into protocols/, restart the server, and the protocol's transactions become available as RPC methods.
cargo runThe server listens on http://0.0.0.0:8080 by default.
All configuration is read from environment variables at startup.
| Variable | Default | Description |
|---|---|---|
PORT |
8080 |
Port the API server listens on. |
NETWORK |
mainnet |
Network / profile name (mainnet, preview, preprod). |
PROTOCOLS_DIR |
./protocols |
Directory scanned for *.tii files at startup. |
TRP_URL |
(not set) | Override the TRP endpoint (uses Demeter public endpoints by default). |
TRP_HEADERS |
(not set) | HTTP headers for the TRP endpoint, comma-separated key=value pairs (e.g. dmtr-api-key=mykey). Used when TRP_URL is set. |
The server implements OpenRPC 1.4.1 for runtime API discovery. The spec is generated dynamically from the loaded .tii files — no manual updates needed.
| Endpoint | Description |
|---|---|
POST / with method rpc.discover |
Returns the full OpenRPC document via JSON-RPC |
GET /openrpc.json |
Returns the OpenRPC document as plain HTTP |
GET /docs |
Redirects to the interactive OpenRPC Playground |
Discover available methods:
curl http://localhost:8080/openrpc.jsonOpen interactive docs:
http://localhost:8080/docs
Methods follow the format <protocol>.<tx>. Parameters are the transaction arguments directly.
Example request:
curl -X POST http://localhost:8080 \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "ticketing-2026.buy_ticket",
"params": {
"buyer": "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3jcu5d8ps7zex2k2xt3uqxgjqnnj83ws8lhrn648jjxtwq2ytjqp"
}
}'Example response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tx": "84a500818258204dce7e..."
}
}- Generate a
.tiifile withtrix build. - Copy it into the
protocols/directory. - Restart the server.
No code changes needed — the server discovers protocols dynamically.
C4 architecture diagrams live in design/001-assets/ as PlantUML sources. To regenerate the SVGs:
docker run --rm \
-v ./design/001-assets:/data \
plantuml/plantuml -tsvg /data/c4-context.puml /data/c4-container.pumlSee design/001-api-scaffolding-spec.md for the scaffolding specification and design/002-openrpc-discovery-spec.md for the OpenRPC discovery specification.
# Build
cargo build
# Run tests
cargo test
# Run with custom config
NETWORK=preview PORT=3000 cargo run