GETTING STARTED

Quickstart

Integrate the Morpheus Privacy Oracle into your Neo smart contracts in under 5 minutes. This guide covers the end-to-end flow from encrypting secrets to reading the TEE-verified result on-chain.

Step 1: Understand the Data Flow

The Morpheus network requires an asynchronous request-callback pattern. You must implement a callback function in your contract to receive the response.

Step 2: Seal Your Parameters (Off-Chain)

Before calling the Oracle contract, encrypt any sensitive API keys or parameters locally. The worker's active X25519 public key is exposed through the frontend proxy and also published on-chain in the Oracle registry metadata.

javascriptEncrypt Parameters
// 1. Fetch TEE Public Key
const res = await fetch("/api/oracle/public-key");
const { public_key } = await res.json();

// 2. Your confidential injection payload
const secrets = {
  "headers": { "Authorization": "Bearer YOUR_PRIVATE_API_KEY" }
};

// 3. Encrypt locally using X25519 + HKDF-SHA256 + AES-256-GCM
const encryptedBlob = await encryptWithOracleX25519(JSON.stringify(secrets), public_key);

Step 3: Submit On-Chain Request

Build a JSON payload, then pass that payload bytestring to the Oracle contract. On Neo N3 the request currently costs 0.01 GAS of prepaid credit; on Neo X the reference interface uses requestFee().

csharpMyOracleConsumer.cs (Neo N3 Mainnet)
// Mainnet Oracle: 0x017520f068fd602082fe5572596185e62a4ad991
// NeoNS alias: oracle.morpheus.neo

public static BigInteger FetchPrivateData(ByteString encryptedBlob)
{
    string payloadJson = "{\"url\":\"https://api.secret.io\","
        + "\"encrypted_params\":\"" + (string)encryptedBlob + "\","
        + "\"json_path\":\"data.price\","
        + "\"target_chain\":\"neo_n3\"}";

    return (BigInteger)Contract.Call(
        OracleHash,
        "request",
        CallFlags.All,
        "oracle",
        (ByteString)payloadJson,
        Runtime.ExecutingScriptHash,
        "onOracleResult"
    );
}

public static void OnOracleResult(BigInteger requestId, string requestType, bool success, ByteString result, string error)
{
    Storage.Put(Storage.CurrentContext, "last_result", result);
}

Step 4: Await the Relayer Callback

Once the transaction is mined, the Morpheus Relayer detects the event, forwards the encrypted payload to the Phala TEE, and then submits a callback transaction back to your contract containing the signed result envelope. If the upstream fetch or compute fails, the request should still finalize with a failure callback instead of being silently dropped.

Zero-Code Testing (Mainnet)

You don't need to write or deploy your own Consumer contract to test Morpheus! We have deployed a universal OracleCallbackConsumer shell on Neo N3 mainnet at 0x89b05cac00804648c666b47ecb1c57bc185821b7.

1. Submit Request: Generate your JSON payload using the Dashboard Oracle Builder. Then, invoke request on the MorpheusOracle ({NETWORKS.neo_n3.oracle}) directly using NeoLine or Neo-CLI:

  • Arg 1 (String): "privacy_oracle" or "compute"
  • Arg 2 (ByteString): Your generated JSON payload string
  • Arg 3 (Hash160): 0x89b05cac00804648c666b47ecb1c57bc185821b7
  • Arg 4 (String): "onOracleResult"
  • Fee: Attach exactly 0.01 GAS to the transaction invocation.

2. Read Result: Check your transaction to get the requestId. Wait about 60 seconds, then perform a read-only invoke of getCallback(requestId) on the consumer script hash above to view your completely executed result envelope!

Previous ArchitectureNextUse Cases
REVISION 1.0.2LAST UPDATED: 2026-03-11