API Reference
Complete technical specifications for the Morpheus smart contracts and the Enclave Javascript SDK.
1. Smart Contract Interface (Neo N3 C#)
The active on-chain interface is the Neo N3 C# call pattern below.
To interact with the Morpheus Oracle on Neo N3 Mainnet, use Contract.Call against 0xf54d8584ef82315c1800373272ab08ae0db2d5ef or NeoNS oracle.morpheus.neo.
2. NeoDID Resolution
NeoDID now also exposes a W3C DID resolution route for public service discovery and subject namespaces:
The resolver exposes the public service DID document, TEE verifier JWK, registry anchors, and subject namespaces without leaking provider UIDs or nullifiers.
3. Enclave SDK (Javascript)
When using built-in compute, Morpheus exposes a fixed catalog of functions. Custom JS compute receives input and helpers; Oracle custom JS receives data, context, and helpers.
hash.sha256HashHashes any JSON-serializable payload with SHA-256.
const digest = await morpheus.hash.sha256({ data: '...' });hash.keccak256HashHashes any JSON-serializable payload with Keccak-256.
const digest = await morpheus.hash.keccak256({ data: '...' });crypto.rsa_verifyCryptoVerifies an RSA-SHA256 signature (computationally efficient in TEE).
const isValid = await morpheus.crypto.rsa_verify(input);math.modexpMathPerforms big integer modular exponentiation.
const result = await morpheus.math.modexp({ base: '2', exponent: '10', modulus: '100' });math.polynomialMathEvaluates a polynomial of arbitrary degree.
const y = await morpheus.math.polynomial({ coefficients: ['1', '0', '1'], x: '2' });matrix.multiplyLinear AlgebraMultiplies two dense matrices.
const matrix = await morpheus.matrix.multiply({ left: [[1,2]], right: [[3],[4]] });vector.cosine_similarityLinear AlgebraComputes cosine similarity between two vectors.
const sim = await morpheus.vector.cosine_similarity({ left: [1,0], right: [0,1] });merkle.rootMerkleBuilds a SHA-256 Merkle root from a list of leaves.
const root = await morpheus.merkle.root({ leaves: ['a', 'b', 'c'] });zkp.public_signal_hashZKPComputes a deterministic digest over public signals.
const hash = await morpheus.zkp.public_signal_hash({ circuit_id: '...', signals: [] });zkp.proof_digestZKPComputes a deterministic digest over a proof object and optional verifying key.
const digest = await morpheus.zkp.proof_digest({ proof, verifying_key });zkp.witness_digestZKPComputes a digest over witness material before proving.
const digest = await morpheus.zkp.witness_digest({ witness, circuit_id: '<circuit-id>' });zkp.groth16.verifyZKPVerifies a Groth16 proof against a verifying key and public signals.
const verdict = await morpheus.zkp.groth16.verify({ verifying_key, public_signals, proof });zkp.groth16.prove.planZKPReturns a planning estimate for Groth16 proving workloads.
const plan = await morpheus.zkp.groth16.prove.plan({ constraints: 120000, witness_count: 4096 });zkp.plonk.prove.planZKPReturns a planning estimate for PLONK proving workloads.
const plan = await morpheus.zkp.plonk.prove.plan({ gates: 90000 });zkp.zerc20.single_withdraw.verifyZKPChecks zERC20 single-withdraw public inputs and can optionally run Groth16 verification.
const verdict = await morpheus.zkp.zerc20.single_withdraw.verify({ public_inputs, proof, verifying_key });fhe.batch_planFHEBuilds a ciphertext batching plan.
const plan = await morpheus.fhe.batch_plan({ slot_count: 4096, ciphertext_count: 8 });fhe.noise_budget_estimateFHEEstimates a rough FHE noise budget.
const estimate = await morpheus.fhe.noise_budget_estimate({ multiplicative_depth: 4, scale_bits: 40, modulus_bits: 218 });fhe.rotation_planFHEReturns a rotation and key-switch planning summary.
const plan = await morpheus.fhe.rotation_plan({ indices: [1, 3, -2] });privacy.maskPrivacyMasks a sensitive string, leaving edges visible.
const masked = await morpheus.privacy.mask({ value: 'secret_key', unmasked_left: 2, unmasked_right: 2 });privacy.add_noisePrivacyAdds simulated Laplace noise for differential privacy.
const noisy = await morpheus.privacy.add_noise({ value: 100, scale: 1.0 });4. Public HTTP API
The Vercel edge app exposes a small set of public JSON endpoints in front of the enclave. All bodies are JSON. POST routes are IP rate-limited; on overflow they return 429 with { error: "Too many requests", retryAfter }. Every rate-limited response carries X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (ISO-8601), and Retry-After (seconds) headers.
| Method | Path | Rate limit | Description |
|---|---|---|---|
| POST | /api/oracle/query | 30 / minute / IP | Off-chain provider fetch + TEE-signed result preview (provider-aware payload resolution). |
| POST | /api/oracle/smart-fetch | 20 / minute / IP | Heuristic provider selection variant of /api/oracle/query. |
| POST | /api/compute/execute | 20 / minute / IP | Run a builtin or custom-JS compute function inside the enclave. Requires target_chain to be neo_n3 when supplied. |
| GET | /api/feeds/[symbol] | unmetered (read) | Latest price quote for a symbol. Accepts ?provider, ?project_slug, ?provider_params (URL-encoded JSON). |
Degraded / fallback shapes
When an upstream provider is unavailable, GET /api/feeds/[symbol] responds with HTTP 200 and a degraded envelope (so callers can distinguish "no quote" from a request error). The upstream status is also surfaced in the x-morpheus-upstream-status header. Invalid input returns HTTP 400 with { error: "..." }.