Repository navigation
API Reference
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Dependency Analysis
- Performance Considerations
- Troubleshooting Guide
- Conclusion
- Appendices
This document describes Sigvara’s oracle REST API endpoints relevant to attestation submission, reputation scoring, and evidence access. It covers:
-
/attest— submit an attestation for a Sigvara agent. -
/score/:didHash— preview the computed score for an agent without writing to chain. -
/evidence/:didHash— retrieve the payments behind an agent’s score with Merkle proofs.
It also documents authentication, rate limiting, error handling, security considerations, input validation, and practical request/response examples.
The oracle is implemented as a Node.js HTTP server that routes requests directly in its main handler. Authentication, body parsing, credential loading, and rate limiting are shared helpers.
graph TB
Client["API Consumer"] --> Server["Oracle HTTP Server<br/>index.js"]
Server --> Helpers["HTTP Helpers<br/>http-helpers.js"]
Server --> Chain["Chain Layer"]
Server --> Payments["Payments Verification"]
Server --> Scoring["Scoring Logic"]
Server --> Store["Persistent State"]
Server --> Merkle["Merkle Utilities"]
Server --> Cache["Response Cache"]
Diagram sources
Section sources
-
Request router: Centralized HTTP handler dispatches paths such as
/attest,/score/:didHash,/evidence/:didHash,/flag,/link,/jobs/<address>,/badge/<address>.svg,/metrics,/epoch, and divergence endpoints. - Authentication: Bearer tokens loaded from environment variables; supports a legacy admin token and named per-service tokens.
-
Rate limiting: In-memory fixed-window limiter keyed by client address (with
X-Forwarded-Forsupport when proxied through loopback). - Payment verification: Optional verified-payment path where a transaction hash proves payment to the agent’s operator address.
- Scoring inputs: Attestations, flags, external ERC-8004 feedback, measured fee volume, activity, and propagation factors.
- Evidence and Merkle proofs: Payment events are exposed with a Merkle root and leaf structure suitable for on-chain verification.
Section sources
- index.js:1135-1291
- index.js:1564-1647
- index.js:1348-1375
- http-helpers.js:40-92
- http-helpers.js:122-169
The oracle exposes read-only and write endpoints. Read endpoints (/score, /evidence) are intentionally unauthenticated but rate-limited. Write endpoints require bearer-token authorization and additional validation.
sequenceDiagram
participant C as "Client"
participant S as "Server index.js"
participant H as "Helpers http-helpers.js"
participant P as "Payments"
participant CH as "Chain"
C->>S : POST /attest { didHash, success, packetId }
S->>H : identifyCaller(headers, credentials)
alt Positive + verified payments enabled
S->>P : verifyPayment(txHash, agentAddress)
P-->>S : credited payer, amount, settledAt
else Negative or payments disabled
S->>S : require bearer token
end
S->>S : check cooldown, update attestations
S->>CH : getAgentInfo(didHash)
CH-->>S : agent info
S-->>C : 200 { didHash, attester, totals, payment? }
Diagram sources
Submits an attestation for a Sigvara agent. The endpoint supports two modes:
- Verified-payment mode: A positive attestation can be submitted without a bearer token if it includes a valid payment transaction proving money moved to the agent’s operator address. Negative attestations still require a bearer token.
-
Token-only mode: When payment verification is not required, a bearer token is always required, and the caller must provide an
attesteridentifier.
- Method:
POST - Path:
/attest - Headers:
-
Authorization:Bearer <token>(required unless positive + verified-payment mode) -
Content-Type:application/json
-
- Body fields:
-
didHash(string, required): 32-byte hex identity hash of the agent. -
success(boolean, required): Whether the work was successful. -
packetId(string, optional): An optional UUID-like identifier used as corroboration when payment verification is enabled. -
payment.txHash(string, optional when payment verification is enabled): Transaction hash used to prove payment to the agent’s operator address. -
attester(string, optional): Unique ID for the attestation source; required when payment verification is disabled.
-
- Success:
200 OK- Fields include
didHash,attester, updated attestation totals, and optionallypayment.txHashandpayment.amount.
- Fields include
- Errors:
-
400 Bad Request: Missing or invalid fields, unknowndidHash, malformedpacketId. -
401 Unauthorized: Missing or invalid bearer token when required. -
402 Payment Required: Invalid payment, self-payment, or other payment-related failure. -
409 Conflict: Settlement already credited. -
429 Too Many Requests: Rate limited or attestation cooldown active. -
502 Bad Gateway: Upstream RPC failure while reading agent info or verifying payment.
-
- If payment verification is enabled and
success === true, no bearer token is required because the payment itself acts as proof. - Negative attestations (
success === false) always require a bearer token. - When payment verification is disabled, a bearer token is always required and
attestermust be provided.
-
didHashmust be present. -
attesteris required when payment verification is disabled. - With payment verification enabled,
txHashis validated against the chain and linked to the agent’s operator address. - Self-payments are rejected.
- Cooldown prevents repeated attestations from the same
attesterto the same agent within a configured window.
- Request:
POST /attest Authorization: Bearer <token> Content-Type: application/json { "didHash": "0x...64-hex...", "success": true, "packetId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "payment": { "txHash": "0x..." } } - Response:
{ "didHash": "0x...64-hex...", "attester": "0x...", "successful": 1, "total": 1, "payment": { "txHash": "0x...", "amount": "1000000000000000000" } }
Section sources
Returns a preview of the computed score for an agent without writing to chain. This endpoint is unauthenticated but rate-limited.
- Method:
GET - Path:
/score/:didHash - Query parameters: None defined for this endpoint.
- Path parameter:
-
didHash(string, required): 32-byte hex identity hash of the agent.
-
- Success:
200 OK- Fields include:
didHashstatusscoresattestations-
weighted(present only when payment verification is enabled), including weighted attestations, distinct payers, activity, trust weight, half-life days, and max per payer. -
flagsandflagWeight -
erc8004AgentId(when linked)
- Fields include:
- Errors:
-
429 Too Many Requests: Rate limited. -
502 Bad Gateway: Upstream RPC failure reading agent info. -
500 Internal Server Error: Unexpected computation failure.
-
- Request:
GET /score/0x...64-hex... - Response:
{ "didHash": "0x...64-hex...", "status": 1, "scores": { ... }, "attestations": { "successful": 10, "total": 12 }, "weighted": { "attestations": { "successful": 8, "total": 10 }, "distinctPayers": 5, "activity": 0.95, "trustWeight": 0.6, "halfLifeDays": 30, "maxPerPayer": 100 }, "flags": 1, "flagWeight": 0.0012, "erc8004AgentId": "123" }
Section sources
Retrieves the payments behind an agent’s score, including Merkle proofs. This endpoint is deliberately unauthenticated so anyone can audit the evidence.
- Method:
GET - Path:
/evidence/:didHash - Path parameter:
-
didHash(string, required): 32-byte hex identity hash of the agent.
-
- Success:
200 OK- Returns JSON containing the agent’s payment events and Merkle root information.
- Errors:
-
400 Bad Request: MalformeddidHash. -
429 Too Many Requests: Rate limited.
-
- The response includes a Merkle root and leaf structure committed to by the oracle.
- Consumers can independently recompute the root over the payment events and compare it with the value stored on-chain.
- The response names the committed fields and leaf order so verifiers do not need to infer them from implementation details.
- Request:
GET /evidence/0x...64-hex... - Response:
{ "didHash": "0x...64-hex...", "root": "0x...", "committedFields": ["txHash","amount","payer","settledAt","blockNumber"], "events": [ { "txHash": "0x...", "amount": "1000000000000000000", "payer": "0x...", "settledAt": 1700000000, "blockNumber": 12345678 } ] }
Section sources
-
/flagand/flag/resolve— Token-gated flag management affecting scores. -
/link— Link a Sigvara agent to an ERC-8004 identity. -
/jobs/<address>— Observation-only ERC-8183 jobs data. -
/badge/<address>.svg— Embeddable SVG badge showing finalized score state. -
/metrics— Prometheus metrics. -
/epoch— Manual epoch trigger (token-gated). -
/divergenceand/divergence/:didHash— Checker-mode disagreement records.
These endpoints share the same authentication and rate-limiting patterns described below.
Section sources
The following diagram shows how the core endpoints depend on shared modules.
graph LR
A["/attest"] --> H["identifyCaller()"]
A --> R["rateLimited()"]
A --> V["verifyPayment()"]
A --> S["store attestations"]
B["/score/:didHash"] --> H
B --> R
B --> M["measuredFactorsFor()"]
B --> C["computeScore()"]
E["/evidence/:didHash"] --> R
E --> ME["getPaymentEvents()"]
E --> MR["buildEvidenceBody()"]
Diagram sources
- index.js:1135-1291
- index.js:1564-1647
- index.js:1348-1375
- http-helpers.js:40-92
- http-helpers.js:122-169
Section sources
- index.js:1135-1291
- index.js:1564-1647
- index.js:1348-1375
- http-helpers.js:40-92
- http-helpers.js:122-169
-
/scoreperforms multiple chain reads (agent info, payer standing, external score when linked). It is rate-limited even though it is public. -
/evidencemay rebuild a Merkle tree over payment events on cache misses; it is rate-limited to bound first-request cost. -
/attestvalidates payments and updates persistent state; it is rate-limited and uses a per-attester cooldown. - Metrics expose counters for rate limits, RPC errors, attestations accepted/rejected, and more.
-
401 Unauthorizedon/attestoccurs when:- A negative attestation is submitted without a bearer token.
- Payment verification is disabled and no bearer token is provided.
- The bearer token does not match any configured credential.
-
Credentials are loaded from:
-
ORACLE_ADMIN_TOKEN(legacy admin token). -
ORACLE_TOKEN_<NAME>variables (per-service tokens).
-
-
Tokens are matched using constant-time comparison against
Authorization: Bearer <token>.
Section sources
-
Global fixed-window rate limiter:
- Window: 60 seconds.
- Max: 60 requests per key per window.
- Key: client IP, with
X-Forwarded-Fortrusted only when the connection arrives via loopback.
-
Responses:
-
429 Too Many Requestswith{ error: "Rate limited" }.
-
Section sources
-
400 Bad Request:- Missing
didHash. - Missing
attesterwhen payment verification is disabled. - Unknown
didHash. - Malformed
packetId.
- Missing
-
402 Payment Required:- Invalid payment.
- Self-payment detected.
-
409 Conflict:- Settlement already credited.
-
429 Too Many Requests:- Rate limited.
- Attestation cooldown active (includes
remainingSecondsandcooldownMs).
-
502 Bad Gateway:- RPC failure reading agent info or verifying payment.
Section sources
-
502 Bad Gateway:- Upstream RPC failure reading agent info.
-
500 Internal Server Error:- Unexpected computation failure; generic message returned to avoid leaking upstream details.
Section sources
-
400 Bad Request:- Malformed
didHash.
- Malformed
-
429 Too Many Requests:- Rate limited.
Section sources
Sigvara’s oracle API provides secure attestation submission, transparent reputation scoring, and auditable evidence with Merkle proofs. Authentication is flexible, supporting both legacy admin tokens and per-service bearer tokens. Public read endpoints are intentionally open but rate-limited. Consumers should handle 429, 401, 402, 409, 502, and 500 responses appropriately, validate inputs, and use /evidence for independent verification of the oracle’s claims.
-
Admin token:
ORACLE_ADMIN_TOKENmaps to theadmincredential name. -
Named tokens:
ORACLE_TOKEN_<NAME>variables define per-service credentials; names are lowercased. -
Header format:
Authorization: Bearer <token>. - Policy enforcement: Non-loopback binds require at least one configured credential; otherwise startup fails.
Section sources
- Fixed window: 60 seconds.
- Maximum: 60 requests per key per window.
- Key derivation:
- Direct socket address for non-loopback connections.
- Last entry in
X-Forwarded-Forfor loopback connections.
Section sources
- Always set bearer tokens before exposing the oracle publicly.
- Prefer per-service tokens for better revocation granularity.
- Use
/evidenceto independently verify Merkle roots and payment events. - Treat
502as upstream failures and retry with backoff. - Respect
429responses and implement exponential backoff. - Validate all inputs on the client side to reduce unnecessary retries.
- Avoid sending sensitive data in logs or error messages.
- Agent Registration and Lifecycle
- Contract Overview and Architecture
- Economic Security Model and Incentives
- Evidence Verification and Merkle Proofs
- Key Management and Rotation
- Maturity Mechanism and Score Release
- Proposal Workflow and Challenge System
- Score Storage and Data Model
- SigvaraIdentity Contract
- SigvaraOracleBond Contract
- SigvaraReputation Contract
- SigvaraStaking Contract
- Slashing Lifecycle and Dispute Resolution
- Stake Management Functions
- Status Management and Control
- Token and Fee Contracts
- Unbonding Period and Withdrawal Security
- Anti-Manipulation and Security Measures
- Community Flag Processing
- Evidence Sources and Verification
- External Trust Integration
- Merkle Proof System
- Oracle Score Computation
- Payment-Backed Attestations
- Scoring Model and Formulas
- Agent Creation and Key Management
- Agent Operations
- Agent Registration Workflow
- Challenge-Response Authentication
- Gate Access Control
- Integration Patterns and Examples
- SDK Overview and Setup
- Verifier Functions